安装greppo依赖Shapely时提示找不到geos_c.dll模块报错
greppo安装Shapely依赖报错解决
问题详情
安装greppo包时流程中断,抛出元数据生成失败错误,完整报错日志:
Collecting Shapely==1.7.1 Using cached Shapely-1.7.1.tar.gz (383 kB) Preparing metadata (setup.py) ... error error: subprocess-exited-with-error × python setup.py egg_info did not run successfully. │ exit code: 1 ╰─> [10 lines of output] Traceback (most recent call last): File "<string>", line 2, in <module> File "<pip-setuptools-caller>", line 34, in <module> File "C:\Users\waqas\AppData\Local\Temp\pip-install-7s68x426\shapely_7bc3527fa38249478d749a0dbc729913\setup.py", line 85, in <module> from shapely._buildcfg import geos_version_string, geos_version, \ File "C:\Users\waqas\AppData\Local\Temp\pip-install-7s68x426\shapely_7bc3527fa38249478d749a0dbc729913\shapely\_buildcfg.py", line 205, in <module> lgeos = CDLL("geos_c.dll") File "C:\Users\waqas\AppData\Local\Programs\Python\Python310\lib\ctypes\__init__.py", line 374, in __init__ self._handle = _dlopen(self._name, mode) FileNotFoundError: Could not find module 'geos_c.dll' (or one of its dependencies). Try using the full path with constructor syntax. [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. error: metadata-generation-failed × Encountered error while generating package metadata. ╰─> See above for output. note: This is an issue with the package mentioned above, not pip. hint: See above for details.
报错核心原因
- 错误出现在安装greppo的固定依赖
Shapely==1.7.1阶段 - 执行setup.py配置时加载
geos_c.dll触发 FileNotFoundError,系统找不到对应dll文件或其依赖,导致包元数据生成失败,安装终止 - 本质是Shapely 1.7.1未提供适配Python 3.10及以上Windows版本的预编译wheel包,pip拉取源码包本地编译时,缺少GEOS底层C库的相关运行文件,无法完成配置。
解决方法
- 优先使用二进制包安装Shapely
执行命令强制pip安装预编译的二进制版本Shapely,这类版本已经内置了所需的GEOS依赖,不需要本地编译:pip install Shapely==1.7.1 --only-binary=:all:
执行完成后重新运行greppo安装命令即可。 - 手动配置GEOS依赖
如果上述命令执行失败,先下载Windows版本的GEOS预编译二进制包,解压后将包内bin目录的路径添加到系统PATH环境变量,重启终端确认系统可识别geos_c.dll后,再重新安装greppo。 - 使用conda环境安装
本地安装有Anaconda/Miniconda的情况下,直接通过conda-forge源安装,conda会自动处理所有底层依赖,不会出现dll缺失问题:conda install -c conda-forge greppo
内容的提问来源于stack exchange,提问作者Muhammad Waqas
相关产品推荐
相关产品推荐

