4

I have created a python environment in my windows system. Python version is 3.6.6 I wanted to install Fiona. Tried using pip command as

pip install Fiona

But got the error as

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.

Tried this also

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

Which is also giving error

    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

Try to install gdal as pip install GDAL-2.4.1-cp36-cp36m-win_amd64.whl and which was successful. But the Fiona installation still giving the error.

How to fix this?

Sreeja
  • 53
  • 1
  • 3
  • pip and gdal don't work well together. My suggestion would be to use the (ana)conda (https://conda.io/en/latest/miniconda.html) package manager for this (from the error it looks like you might already be using anaconda). `conda install conda-forge::fiona` typically works flawlessly for me. – Swier Dec 11 '19 at 11:59
  • Have a look at the following question on the GIS stack exchange: https://gis.stackexchange.com/q/28966/88989 – Swier Dec 11 '19 at 12:02
  • As @Swier wrote, pip and GDAL don't work well together - that's especially true if you work on windows. I'd recommend getting a pre-built wheel from [Chris Goehlke's excellent site](https://www.lfd.uci.edu/~gohlke/pythonlibs/#gdal) and install it manually before you pip-install fiona. Just be sure to select the correct one depending on your system & python version! – Val Dec 19 '19 at 08:32

1 Answers1

0

I have Windows 10 and I have same problem with geopandas.

You can try this solution BUT remember that before install geopandas you also need install GDAL (same method that on link above via .whl for GDAL works fine). It wasn't worked for me first time, but worked when I reinstall fiona to 1.8.6 version (because v.2+ gets errors)

I wanted to install geopandas, but before it I had to install Fiona. And this was my solution:

  1. Download binary gdal from here. I choosed this: release-1911-x64-gdal-2-4-4-mapserver-7-4-3.

    1.1. You need to download 1 zip-file: release-1911-x64-gdal-2-4-4-mapserver-7-4-3-libs.zip

    1.2. Extract this to local path, e.g. "C:\\Users\\Jack\\Gdal"

  2. Download Fiona from master. You can download zip now

  3. Unpacking Fiona-master.zip, e.g. "C:\\Users\\Jack\\Fiona-master"

  4. Open CMD, open dir "Fiona-master": chdir "C:\\Users\\Jack\\Fiona-master" and run this (with your paths):

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

    In my case:

    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. I didn't have cython and got error, so: pip install cython

  6. Again try run long string from (4)

  7. After success: pip install geopandas worked fine

Jackssn
  • 1,346
  • 1
  • 14
  • 16