4

我在我的 Windows 系统中创建了一个 python 环境。Python 版本是 3.6.6 我想安装 Fiona。尝试使用 pip 命令作为

pip install Fiona

但得到的错误为

Collecting Fiona
  Using cached https://files.pythonhosted.org/packages/be/04/31d0a6f03943b1684f32c9b861be40c1fd282468fa6bd54ddf4a774e6b0f/Fiona-1.8.13.tar.gz
    ERROR: Command errored out with exit status 1:
     command: 'c:\users\User\myenv\scripts\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\User\\AppData\\Local\\Temp\\pip-install-1dhz9c5u\\Fiona\\setup.py'"'"'; __file__='"'"'C:\\Users\\User\\AppData\\Local\\Temp\\pip-install-1dhz9c5u\\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\User\AppData\Local\Temp\pip-install-1dhz9c5u\Fiona\pip-egg-info'
         cwd: C:\Users\User\AppData\Local\Temp\pip-install-1dhz9c5u\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.

这个也试过

pip install Fiona-1.8.13-cp36-cp36m-win_amd64.whl

这也给出了错误

    building 'osgeo._gdal' extension
      creating build\temp.win-amd64-3.6
      creating build\temp.win-amd64-3.6\Release
      creating build\temp.win-amd64-3.6\Release\extensions
      C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.24.28314\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MT -I../../port -I../../gcore -I../../alg -I../../ogr/ -I../../ogr/ogrsf_frmts -I../../gnm -I../../apps -Ic:\users\User\anaconda3\include -Ic:\users\User\anaconda3\include -Ic:\users\User\myenv\lib\site-packages\numpy\core\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.24.28314\ATLMFC\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.24.28314\include" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\cppwinrt" /EHsc /Tpextensions/gdal_wrap.cpp /Fobuild\temp.win-amd64-3.6\Release\extensions/gdal_wrap.obj
      gdal_wrap.cpp
      extensions/gdal_wrap.cpp(3173): fatal error C1083: Cannot open include file: 'cpl_port.h': No such file or directory
      error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.24.28314\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2
      ---------------------------------------

-
  ERROR: Failed building wheel for gdal

尝试安装 gdalpip install GDAL-2.4.1-cp36-cp36m-win_amd64.whl并成功。但是 Fiona 安装仍然报错。

如何解决这个问题?

4

1 回答 1

0

我有 Windows 10,我对 geopandas 也有同样的问题。

您可以尝试此解决方案,但请记住,在安装 geopandas 之前,您还需要安装 GDAL(通过 .whl 的 GDAL 链接上面的方法可以正常工作)。第一次对我不起作用,但是当我将 fiona 重新安装到 1.8.6 版本时起作用(因为 v.2+ 出现错误)

我想安装geopandas,但在此之前我必须安装Fiona。这是我的解决方案:

  1. 从这里下载二进制 gdal 。我选择了这个:release-1911-x64-gdal-2-4-4-mapserver-7-4-3

    1.1。您需要下载 1 个 zip 文件:release-1911-x64-gdal-2-4-4-mapserver-7-4-3-libs.zip

    1.2. 将此提取到本地路径,例如"C:\\Users\\Jack\\Gdal"

  2. 从master下载 Fiona 。您现在可以下载 zip

  3. 解压 Fiona-master.zip,例如"C:\\Users\\Jack\\Fiona-master"

  4. 打开 CMD,打开 dir "Fiona-master":chdir "C:\\Users\\Jack\\Fiona-master"并运行它(使用你的路径):

    python setup.py build_ext -I"<PATH_TO_GDAL_INCLUDE_DIR>" -lgdal_i -L"<PATH_TO_GDAL_LIB_DIR>" install --gdalversion 2.1

    就我而言:

    python setup.py build_ext -I"C:\\Users\\Jack\\Gdal\\include" -lgdal_i -L"C:\\Users\\Vasilev_EN\\Downloads\\Gdal\\lib" install --gdalversion 2.1

  5. 我没有 cython 并出现错误,所以:pip install cython

  6. 再次尝试从 (4) 运行长字符串

  7. 成功后:pip install geopandas工作正常

于 2021-08-03T15:52:50.523 回答