使用import shapely
不会返回任何错误,但是使用import shapely.geometry
或from shapely import geometry
会返回以下错误:
Traceback (most recent call last):
File "C:\Python36\lib\site-packages\shapely\geos.py", line 120, in <module>
os.path.dirname(__file__), "DLLs", "geos_c.dll")))
File "C:\Python36\lib\ctypes\__init__.py", line 348, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] The specified module could not be found
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python36\lib\site-packages\shapely\geometry\__init__.py", line 4, in <module>
from .base import CAP_STYLE, JOIN_STYLE
File "C:\Python36\lib\site-packages\shapely\geometry\base.py", line 17, in <module>
from shapely.coords import CoordinateSequence
File "C:\Python36\lib\site-packages\shapely\coords.py", line 8, in <module>
from shapely.geos import lgeos
File "C:\Python36\lib\site-packages\shapely\geos.py", line 122, in <module>
_lgeos = CDLL("geos_c.dll")
File "C:\Python36\lib\ctypes\__init__.py", line 348, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] The specified module could not be found
打开Python解释器会打印出Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 17:00:18) [MSC v.1900 64 bit (AMD64)] on win32
,因此我使用Shapely‑1.6.4.post1‑cp36‑cp36m‑win_amd64.whl
从https://www.lfd.uci.edu/~gohlke/pythonlibs/#shapely下载并安装了pip
文件
我的C:\Python36\Lib\site-packages
目录包含文件夹shapely
和Shapely-1.6.4.post1.dist-info
,并且确实存在geometry
子文件夹,这使我相信该软件包确实安装正确。