【问题标题】:Error installing geopandas:“ A GDAL API version must be specified ” in Visual Studio Code安装 geopandas 时出错:“必须指定 GDAL API 版本”在 Visual Studio Code 中
【发布时间】:2020-09-29 15:10:00
【问题描述】:

在 vs 代码中安装 geopandas 时出现此错误。我一直在网上寻找它的解决方案,但他们都没有真正解释发生了什么以及如何解决它..

Collecting geopandas
  Downloading geopandas-0.7.0-py2.py3-none-any.whl (928 kB)
     |████████████████████████████████| 928 kB 726 kB/s
Collecting shapely
  Downloading Shapely-1.7.0-cp38-cp38-win32.whl (895 kB)
     |████████████████████████████████| 895 kB 437 kB/s
Requirement already satisfied: pandas>=0.23.0 in c:\users\mayank\appdata\local\programs\python\python38-32\lib\site-packages (from geopandas) (1.0.3)
Collecting fiona
  Downloading Fiona-1.8.13.post1.tar.gz (1.2 MB)
     |████████████████████████████████| 1.2 MB 506 kB/s
    ERROR: Command errored out with exit status 1:
     command: 'C:\Users\mayank\AppData\Local\Programs\Python\Python38-32\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\mayank\\AppData\\Local\\Temp\\pip-install-1le2w4at\\fiona\\setup.py'"'"'; __file__='"'"'C:\\Users\\mayank\\AppData\\Local\\Temp\\pip-install-1le2w4at\\fiona\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\mayank\AppData\Local\Temp\pip-pip-egg-info-e_ca92eu'
         cwd: C:\Users\mayank\AppData\Local\Temp\pip-install-1le2w4at\fiona\
    Complete output (1 lines):
    A GDAL API version must be specified. Provide a path to gdal-config using a GDAL_CONFIG environment variable or use a GDAL_VERSION environment variable.
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

【问题讨论】:

  • 在 Windows 上,如果您使用 conda 安装软件包,特别是从 conda-forge 频道(例如,conda create --name=gis python=3.7 geopandas rasterio descartes --channel=conda-forge)安装包,您的生活会轻松很多。
  • 但是我没有anaconda....除了这个还有什么解决办法吗?@PaulH
  • 也许有。但是 conda 是免费的,并且可以更轻松地设置基于 GIS 的环境。

标签: python pandas gdal geopandas fiona


【解决方案1】:

作为 geopandas 依赖项的 Fiona 需要一个 GDAL 实例。安装时需要查看 PATH 环境变量以找到 GDAL 位置。如果 PATH 没有引用,则无法安装。我发现一个解决方法是获取 GDAL 和 fiona whl 文件并从本地副本安装。

【讨论】:

    【解决方案2】:

    首先你需要做的是安装gdal 包。我通过 pip 安装它:

    pip install https://download.lfd.uci.edu/pythonlibs/w4tscw6k/GDAL-3.2.2-cp39-cp39-win_amd64.whl
    

    提示:不要通过正常的pip用法直接安装: pip install gdal 。您可以为您的 python3.x Here 找到兼容的 gdal 版本。

    安装gdal后,可以为fiano安装,例如:

    pip install https://download.lfd.uci.edu/pythonlibs/w4tscw6k/Fiona-1.8.18-cp39-cp39-win_amd64.whl
    

    终于可以全部安装成功了……

    【讨论】:

      猜你喜欢
      • 2019-07-11
      • 2020-10-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-12-11
      • 2011-11-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多