本文最后更新于:2024年1月14日 晚上

在Windows python中使用 from shapely.geos import lgeos 会报错,错误一般由于调用了依赖**shapely** 库的代码,比如我就是在调用 imgaugclip_out_of_image函数时报错,本文记录解决方案。

问题复现

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
poly.clip_out_of_image(image_aug)

Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\Admin\AppData\Roaming\Python\Python37\site-packages\imgaug\augmentables\polys.py", line 575, in clip_out_of_image
import shapely.geometry
File "C:\Users\Admin\AppData\Roaming\Python\Python37\site-packages\shapely\geometry\__init__.py", line 4, in <module>
from .base import CAP_STYLE, JOIN_STYLE
File "C:\Users\Admin\AppData\Roaming\Python\Python37\site-packages\shapely\geometry\base.py", line 18, in <module>
from shapely.coords import CoordinateSequence
File "C:\Users\Admin\AppData\Roaming\Python\Python37\site-packages\shapely\coords.py", line 8, in <module>
from shapely.geos import lgeos
File "C:\Users\Admin\AppData\Roaming\Python\Python37\site-packages\shapely\geos.py", line 145, in <module>
_lgeos = CDLL(os.path.join(sys.prefix, 'Library', 'bin', 'geos_c.dll'))
File "E:\Program_Files\Annoconda\lib\ctypes\__init__.py", line 356, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] 找不到指定的模块。

解决方案

我们看到里面有一个关于geos_c.dll的文件,而报错的主要原因就出现在geos_c.dll这里,看了网上很多文章大部分说是geos_c.dll文件缺失的原因。

参考资料



文章链接:
https://www.zywvvd.com/notes/coding/python/windows-shapely-error/windows-shapely-error/


“觉得不错的话,给点打赏吧 ୧(๑•̀⌄•́๑)૭”

微信二维码

微信支付

支付宝二维码

支付宝支付

windows 调用 from shapely.geos import lgeos 时报错
https://www.zywvvd.com/notes/coding/python/windows-shapely-error/windows-shapely-error/
作者
Yiwei Zhang
发布于
2021年5月21日
许可协议