如何使用 WinPython 让 geopandas 在 Windows 10 上工作?

How do I get geopandas to work on Windows 10 with WinPython?

我在 Windows 10 上使用 WinPython 和 Python 3.6,通过漫长而曲折的课程,我设法安装了 geopandas 并在我的系统上正常工作。这需要手动安装各种依赖项,如 GDAL、Fiona 和 PyProj,但它最终运行良好。

几天后(在此期间计算机处于休眠状态)我正在尝试 运行 运行良好的相同代码,现在我得到了

Could not find lib geos_c.dll or load any of its variants

在代码 import geopandas as gp 上,当它到达 from shapely.geos import lgeos 时。我已经确认我确实已经很好地安装了(通过 pip)并且我有 geos_c.dll,但它正在寻找这里

C:\WinPython\python-3.6.5.amd64\Library\lib\geos_c.dll'

而文件实际上在这里:

C:\WinPython\python-3.6.5.amd64\Lib\site-packages\osgeo

事实上,我的 python 文件夹中甚至没有 Library 目录。

所以我重新安装了 Shapely,但这次使用的是 whl 文件,当被 import geopandas 调用时,错误变为 module 'shapely' has no attribute 'affinity'。 运行 from shapely import affinity 不会导致错误。我不知道为什么这些软件包很难安装或运行,但我很想知道....

How do I get geopandas to work on Windows 10 with WinPython?

或者说真的,既然它几天前工作了,而且在计算机休眠时应该没有任何改变,如何让它像以前一样工作?

我建议下载 shapely 的轮子并手动安装。您可以从 https://www.lfd.uci.edu/~gohlke/pythonlibs/#shapely 下载轮子(选择 python 版本 36 和 32 或 64 位 windows)。

然后安装:

pip install Shapely‑1.6.4.post1‑cp36‑cp36m‑win_amd64.whl

也许我应该删除我的问题,但 "solution" 是 重新启动我的 Python IDE。在 Spyder 中重新启动内核并没有改变任何东西,但是我完全关闭了 Spyder 并且只是重新 运行 相同而不改变任何东西并且它 运行 很好。我不知道我所做的任何更改是否真的有帮助(因为,正如我所说,几天前它运行良好)。

将 goes_c 重命名为 goes,它最终会起作用。