Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot load libgrass_gis.8.3.so #671

Open
2 of 8 tasks
HuidaeCho opened this issue Feb 10, 2023 · 0 comments
Open
2 of 8 tasks

Cannot load libgrass_gis.8.3.so #671

HuidaeCho opened this issue Feb 10, 2023 · 0 comments

Comments

@HuidaeCho
Copy link

HuidaeCho commented Feb 10, 2023

Description

I'm not sure where to report this issue. It might be a bug in the core GRASS (ctypes_loader.py?), but it only happens with PyWPS.

gisbase in the config file has no effect and the grass_gis.8.3 library cannot be loaded (it was actually found, but its first dependency libgrass_datetime.8.3.so was not found even though it's in the same directory).

$ uwsgi --socket :8080 --wsgi-file wps.py 
*** Starting uWSGI 2.0.20 (64bit) on [Fri Feb 10 02:48:34 2023] ***
compiled with version: 11.2.0 on 14 March 2022 10:14:17
os: Linux-5.15.80 #1 SMP PREEMPT Sun Nov 27 13:28:05 CST 2022
nodename: me.x
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 8
current working directory: /www/txmod
detected binary path: /usr/local/bin/uwsgi
*** WARNING: you are running uWSGI without its master process manager ***
your processes number limit is 192676
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to TCP address :8080 fd 3
Python version: 3.9.16 (main, Dec  7 2022, 11:34:25)  [GCC 11.2.0]
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x727c20
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 72920 bytes (71 KB) for 1 cores
*** Operational MODE: single process ***
WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0x727c20 pid: 20350 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI worker 1 (and the only) (pid: 20350, cores: 1)
[pid: 20350|app: 0|req: 1/1] 174.56.8.172 () {66 vars in 1068 bytes} [Fri Feb 10 02:48:40 2023] POST /wps/ => generated 975 bytes in 133 msecs (HTTP/1.1 200) 2 headers in 79 bytes (1 switches on core 0)
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/pywps/app/Process.py", line 243, in _run_process
    self._set_grass(wps_request)
  File "/usr/local/lib/python3.9/site-packages/pywps/app/Process.py", line 421, in _set_grass
    from grass.pygrass.gis import make_mapset
  File "/usr/grass/grass/dist.x86_64-pc-linux-gnu/etc/python/grass/pygrass/gis/__init__.py", line 19, in <module>
    import grass.lib.gis as libgis
  File "/usr/grass/grass/dist.x86_64-pc-linux-gnu/etc/python/grass/lib/gis.py", line 30, in <module>
    _libs["grass_gis.8.3"] = load_library("grass_gis.8.3")
  File "/usr/grass/grass/dist.x86_64-pc-linux-gnu/etc/python/grass/lib/ctypes_loader.py", line 105, in __call__
    raise ImportError("Could not load %s." % libname)
ImportError: Could not load grass_gis.8.3.

Setting LD_LIBRARY_PATH outside the pywps script works fine.

I tried:

  • Printing os.environ["LD_LIBRARY_PATH"] before _libs["grass_gis.8.3"] = load_library("grass_gis.8.3") in etc/python/grass/lib/gis.py (GRASS path) and confirmed /usr/local/src/grass/dist.x86_64-pc-linux-gnu/lib is in LD_LIBRARY_PATH.
  • Printing the Exception message before pass inside def __call__() in etc/python/grass/lib/ctypes_loader.py revealed an indirect reason:
/usr/grass/grass/dist.x86_64-pc-linux-gnu/lib/libgrass_gis.8.3.so
libgrass_datetime.8.3.so: cannot open shared object file: No such file or directory

But still, /usr/grass/grass/dist.x86_64-pc-linux-gnu/lib in os.environ["LD_LIBRARY_PATH"] is not honored for libgrass_datetime.8.3.so. Looks like it's just one depth of search and if a GRASS library requires another in that directory, it cannot find the second library? Why is it only happening with PyWPS then?

Environment

  • operating system: Linux
  • Python version: 3.9.16
  • PyWPS version: 4.5.2
  • source/distribution
  • git clone
  • Debian
  • PyPI
  • zip/tar.gz
  • other (please specify):
  • web server
  • Apache/mod_wsgi
  • CGI
  • other (please specify): Apache/mod_proxy_uwsgi

Steps to Reproduce

wps.py

#!/usr/bin/env python3
from pywps.app import Service
from grasstmod import GrassTmod

application = Service([GrassTmod()], ["/www/txmod/wps.cfg"])

wps.cfg

...
[grass]
gisbase=/usr/grass/grass/dist.x86_64-pc-linux-gnu/

Additional Information

Workaround

LD_LIBRARY_PATH=/usr/grass/grass/dist.x86_64-pc-linux-gnu/lib uwsgi --socket :8080 --wsgi-file wps.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant