Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Cannot load libgrass_gis.8.3.so

未关闭
#671 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
python
领域
api, backend

调研方向

从 etc/python/grass/lib/ctypes_loader.py 和 etc/python/grass/lib/gis.py 开始,然后使用提供的 wps.py 和 wps.cfg 跟踪 PyWPS 的 Process.py _set_grass 路径。在有和没有 LD_LIBRARY_PATH workaround 的情况下通过 uWSGI 重现问题,并确定 GRASS 依赖项未在 PyWPS 环境中加载的原因。完成的标准是:在该设置中加载所报告的 GRASS 库,且不依赖外部 workaround。

由索引模型根据 Issue 内容生成。

描述

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
主要语言
Python
星标
186
派生
117
平均合并
11 天 20 小时
30 天内合并 PR
1

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

geopython/pywps 的其他 Issue

查看 geopython/pywps 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。