在Windows上安装geopandas的pip命令

4
我对Python相对陌生,并尝试使用pip在Python 3.7上安装geopandas。 由于某些原因,我想避免使用anaconda分发版。根据这篇文章的指导,我首先手动安装了依赖项,成功安装了geopandas。但问题是,当我尝试导入geopandas时出现了问题。
import geopandas

接下来的错误信息为:

File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\site-packages\geopandas\__init__.py", line 5, in <module>
from geopandas.io.file import read_file

File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\site-packages\geopandas\io\file.py", line 4, in <module>
import fiona

File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\site-packages\fiona\__init__.py", line 87, in <module>
from fiona.collection import BytesCollection, Collection

File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\site-packages\fiona\collection.py", line 9, in <module>
from fiona.ogrext import Iterator, ItemsIterator, KeysIterator

ImportError: DLL load failed: The specified module could not be found.

任何建议都将不胜感激。

自那时以来,你做了什么? - keepAlive
1
我放弃了,使用anaconda发行版。出于某种原因,在那里它运行良好。如果您不想要完整的发行版,可以安装miniconda,然后conda install -c conda-forge geopandas会自动安装所有依赖项。 - Robusta
3个回答

22

我的情况与你类似。以下是我如何设置我的步骤:

平台: Windows 10,64位Python版本: Python 3.7

依赖项(需要的whl文件):

  1. GDAL-3.0.4-cp37-cp37m-win_amd64.whl
  2. Fiona-1.8.13-cp37-cp37m-win_amd64.whl
  3. pyproj-2.6.0-cp37-cp37m-win_amd64.whl
  4. Rtree-0.9.4-cp37-cp37m-win_amd64.whl

步骤:

  1. https://www.lfd.uci.edu/~gohlke/pythonlibs/

    下载与平台和Python版本匹配的文件

  2. 安装软件包(按顺序执行)

a) C:\Users...\Python37\Scripts>pip3.7 install C:...\GDAL-3.0.4-cp37-cp37m-win_amd64.whl

b) C:\Users...\Python37\Scripts>pip3.7 install C:...\Fiona-1.8.13-cp37-cp37m-win_amd64.whl

c) C:\Users...\Python37\Scripts>pip3.7 install C:...\pyproj-2.6.0-cp37-cp37m-win_amd64.whl

d) C:\Users...\Python37\Scripts>pip3.7 install C:...\Rtree-0.9.4-cp37-cp37m-win_amd64.whl

  1. 如果没有错误,现在可以开始了:

C:\Users...\Python37\Scripts>pip3.7.exe install geopandas

  1. 使用 IDEL 3.7.4 进行测试

    import geopandas as pdg

(它起作用了!)

这对我有用,我希望对你也有所帮助。


2
我在安装GDAL时遇到了问题,但是.whl文件帮助了我。https://gis.stackexchange.com/questions/343835/installing-rasterio-and-gdal-api-in-a-virtuallenv-in-windows-10/371720#371720 - ArashMad
非常完美,谢谢!在安装geopandas之前,我也使用了与其他软件相同的方法安装了_shapely_,因为他们在他们的网站上提到了它。也许这没有什么区别?另外,在此之前需要使用pip install wheel吗? - Lawrence
您提出的步骤在 Windows 10 上使用 Python 3.8.8 也非常有效。 - jaweej
谢谢。在 Windows 10 amd64 上,使用 Python 3.10 尝试一下,它也可以正常工作。 - Mahdi Nazari

0

0
最简单的安装geopandas的方法是:
conda install geopandas

为了将geopandas更新到最新版本,请在通过conda安装后使用以下命令:

pip install geopandas --upgrade 

Geopandas官方网站中还有其他的安装方法。

当涉及到安装时,Conda非常强大,因为它会安装包所需的依赖项。但是,如果您想要提前安装依赖项,请使用以下命令:

conda install pandas fiona shapely pyproj rtree descartes

请注意,如果您已经使用上述命令安装了依赖项,则也可以使用pip安装geopandas,但在通过pip安装之前,需要先安装依赖项。要了解更多有关依赖项的信息,请参阅官方指南。要使用pip安装,请使用以下命令:
pip install geopandas

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接