简体   繁体   English

Windows 64 上的 Python、GEOS 和 Shapely

[英]Python, GEOS and Shapely on Windows 64

When trying to install Shapely on my Windows 64bit computer, I cannot get the GEOS library to work.尝试在我的 Windows 64 位计算机上安装 Shapely 时,我无法让 GEOS 库工作。

So far, I have run the OSGeo4W installer from which I installed GDAL (I believe the geos library is included in that package).到目前为止,我已经运行了 OSGeo4W 安装程序,我从中安装了 GDAL(我相信 geos 库包含在该包中)。 After that, I checked and I have geos_c.dll on my C:\\OSGeo4W\\bin directory, but either I have missed some configuration steps or the library does not work.之后,我检查了我的C:\\OSGeo4W\\bin目录中是否有 geos_c.dll,但要么我错过了一些配置步骤,要么库不起作用。

I need Shapely to work, so I also ran pip install shapely after installing GDAL, and it apparently worked (although it could not find the C library for GEOS).我需要 Shapely 才能工作,所以我在安装 GDAL 后还运行了pip install shapely ,它显然有效(尽管它找不到 GEOS 的 C 库)。

In my code, I can import Shapely, but when I try to use it, I get an error telling me "geos.dll" is not found.在我的代码中,我可以导入 Shapely,但是当我尝试使用它时,我收到一条错误消息,告诉我"geos.dll"

Any help with this will be very appreciated.对此的任何帮助将不胜感激。 Thanks!谢谢!

Anaconda/Miniconda users should install Shapely (and dependencies) with: Anaconda/Miniconda 用户应该安装 Shapely(和依赖项):

conda install shapely

As of 2020, other Python users can install binary wheels from PyPI with pip:截至 2020 年,其他 Python 用户可以使用 pip 从 PyPI 安装二进制轮子:

pip install shapely

(you may need --upgrade to get at least version 1.7.0, when binary wheels were added.) Note that binary wheels are not available for Python 2 on Windows. (您可能需要--upgrade来获得至少 1.7.0 版,当添加二进制轮时。)请注意,二进制轮不适用于 Windows 上的 Python 2。


Another resource for Windows users with Python installed from python.org, Christoph Gohlke maintains an excellent pool of Unofficial Windows Binaries for Python.另一个从 python.org 安装 Python 的 Windows 用户资源,Christoph Gohlke 维护了一个优秀的 Python 非官方 Windows 二进制文件池。 Download the Shapely wheels for 32- or 64-bit versions of Python, which includes GEOS dependencies.下载适用于 32 位或 64 位 Python 版本的Shapely 轮子,其中包括 GEOS 依赖项。

see my answer here https://stackoverflow.com/a/50623996/1683626在此处查看我的答案https://stackoverflow.com/a/50623996/1683626

on windows 10, python 3.6.5 64bit在 Windows 10 上,python 3.6.5 64 位

  • install osgeo4w安装osgeo4w
  • add installed folder to path eg C:\\OSGeo4W64\\bin (must contain geos_c.dll)将安装的文件夹添加到路径,例如 C:\\OSGeo4W64\\bin(必须包含 geos_c.dll)
  • restart command line重启命令行

There is an version of Shapely available here that includes geos in the installer.有身材匀称的可用的版本,在这里,其中包括在安装GEOS。 Look at the bottom of the page.查看页面底部。

I tried the method of @jozef but failed even I imported the folder to the path.我尝试了@jozef 的方法,但即使将文件夹导入路径也失败了。

A straightforward solution: add geos_c.dll, geos.dll to the library folder of your python environment.一个简单的解决方案:将 geos_c.dll、geos.dll 添加到您的 python 环境的库文件夹中。 Then it works.然后它起作用了。

I used the command below and it did work;我使用了下面的命令,它确实有效;

pip install Shapely==1.3.0 pip install Shapely==1.3.0

I've made it installing wheels for GDAL (and Fiona, in my case; might not be required) from https://www.lfd.uci.edu/~gohlke/pythonlibs/#gdal Providing a path to the geos_c.dll didn't work.我已经从https://www.lfd.uci.edu/~gohlke/pythonlibs/#gdal为 GDAL(和 Fiona,在我的情况下;可能不需要)安装轮子提供了到 geos_c.dll 的路径没有用。 Neither putting them into venv/Lib.既不将它们放入 venv/Lib 中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM