31

I've done a software on Ubuntu, and I'm having several problems running this software on Windows.

My biggest issue point now is that I'm trying to install "fiona" - I have it already installed on my PIP packages - but for some reason it's not working.

So I've tried to install it via setup download from the original repository.

By following the rules: using python setup.py install

I've already added some environment variables as:

GDAL_DATA GDAL_DRIVER_PATH 

and beyond that I've added on variable PATH the path of GDAL

There's another way to do it, by using another command but I don't how would it be

gdal include files

gdal library

python setup.py build_ext -I<path to gdal include files> -lgdal_i -L<path to gdal library> install --gdalversion 2.1

My current version of GDAL is GDAL 1.11.4, released 2016/01/25

I'd already tried with 2.3 etc. and it didn't work.

I've tried using only this command:

python setup.py install --gdalversion 1.11

fiona/_geometry.c(578) : fatal error C1083: Cannot open include file: 'ogr_api.h ': No such file or directory

Which results when I try to use a software that has fiona, I receive the following error:

    import fiona
  File "C:\Python27\fiona\__init__.py", line 81, in <module>
    from fiona.collection import Collection, BytesCollection
  File "C:\Python27\fiona\collection.py", line 9, in <module>
    from fiona.ogrext import Iterator, ItemsIterator, KeysIterator
ImportError: No module named ogrext
1
  • 1
    If you do not care about which python distribution to use, I have found it way easier to install GDAL, Fiona etc from conda-forge in miniconda.
    – the_cheff
    Commented Jun 19, 2018 at 5:43

8 Answers 8

26

When building from source on Windows, it is important to know that setup.py cannot rely on gdal-config, which is only present on UNIX systems. On Windows, these paths need to be provided by the user. You will need to find the include files and the library files for gdal and use setup.py

The GDAL DLL files and gdal-data directory need to be in your Windows PATH otherwise building Fiona will fail to work.

Follow below steps to install Fiona and geopandas on windows

Step 1: Download the Fiona wheel from this website. please pick the .whl package that correlates with your python interpreter as well system build (i.e. 32 bit or 64 bit)

Step 2: Install fiona by using pip install path/to/fiona.whl

Step 3: Install geopandas by using 'pip install geopandas'

7
  • What .dll files? I know of one .dll file the gdal301.dll, any other dll files I need to add to my path?
    – icypy
    Commented Nov 27, 2020 at 21:54
  • 14
    This was helpful but I would add Step 0: Install GDAL (the same way you would install Fiona) lfd.uci.edu/~gohlke/pythonlibs/#gdal
    – Jacky
    Commented Apr 14, 2021 at 22:32
  • 1
    On my W10 x64 there is not way of installing it :( ERROR: Fiona-1.8.19-cp39-cp39-win_amd64.whl is not a supported wheel on this platform. ERROR: Fiona-1.8.19-cp39-cp39-win32.whl is not a supported wheel on this platform.
    – rheras
    Commented Apr 16, 2021 at 10:21
  • 1
    @MartimPassos Note the cpXX notation should match your Python version. GDAL major and minor version also needs to match Fiona's expectations. For example, I have Python 3.9 installed on my Windows 10 x64 machine, so I downloaded and installed GDAL-3.2.3-cp39-cp39-win_amd64.whl and Fiona-1.8.19-cp39-cp39-win_amd64.whl, in that order.
    – Phlucious
    Commented Aug 3, 2021 at 21:14
  • 1
    I agree with @MartimPassos that cpXX should match the Python version and you should also rightly select win** for 32- or 64-bit based on your system. I was losing a lot of my time, but when I selected the right version, I could install the package instantly.
    – hbstha123
    Commented Aug 14, 2021 at 15:17
21

To install Fiona on windows, you need to follow the below-mentioned steps: -

  1. You need to install GDAL wheel file using the link . After visiting this link, download this file named GDAL‑3.0.4‑cp37‑cp37m‑win32.whl since it worked for me and then use the command
pip install c:\Users\........\GDAL‑3.0.4‑cp37‑cp37m‑win32.whl

to successfully install GDAL which is the requirement of Geopandas.

  1. After installing the GDAL, you need to install a Fiona wheel file using the link. Upon visiting this link, download the file named Fiona‑1.8.13‑cp37‑cp37m‑win32.whl since it is the supported wheel file for most of the windows users. After downloading this file, use the command
pip install c:\Users\........\Fiona‑1.8.13‑cp37‑cp37m‑win32.whl

NOTE: If the above-mentioned wheel file doesn't work for you, then try using alternate wheel files.

4
  • pip install e:\GDAL-3.0.4-cp36-cp36m-win32.whl ERROR: GDAL-3.0.4-cp36-cp36m-win32.whl is not a supported wheel on this platform. (on W10 x64) :(
    – rheras
    Commented Apr 16, 2021 at 10:30
  • pip install e:\GDAL-3.2.2-cp39-cp39-win_amd64.whl ERROR: GDAL-3.2.2-cp39-cp39-win_amd64.whl is not a supported wheel on this platform. :( on W10 x64
    – rheras
    Commented Apr 16, 2021 at 10:30
  • @rheras have you tried another version? Just installed 3.3.1 for Python 3.9 (Win10 x64) with this method.
    – thoroc
    Commented Jul 7, 2021 at 21:01
  • 1
    It works! But I am curious how to choose the right package? I understand the win_amd64 is for the Windows 64-bits system but does cp39 means the Python 3.9 version?
    – Woden
    Commented Sep 30, 2021 at 13:41
11

Finally after 6 hours of trying like crazy for installing Fiona. I will try to make it as simple as possible. Most of the guide are taken from here How to install GDAL

Download the required gdal file here:

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

2) Then you can install the wheel file:

python.exe -m pip install GDAL-2.2.4-cp35-cp35m-win_amd64.whl

3) Add Environment Variable with the name GDAL_DATA and value =

C:\Users\yourUserName\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\osgeo\data\gdal

4) In most cases we require Visual C++ build tools. Install only the build tools and launch or download c++ visual studio from official link, Link to shortcut download from here:

Visual C++ 2015 Build Tools

5) Now install suitable fiona wheel from here here

and run: pip install C:/path/to/Fiona‑1.8.4‑cp37‑cp37m‑win32.whl

6) run pip install fiona

3
  • 1
    thanks, but none of them are accepted by my Windows10 x64: ERROR: Fiona-1.8.19-cp39-cp39-win32.whl is not a supported wheel on this platform. .... and so on with all :(
    – rheras
    Commented Apr 16, 2021 at 10:25
  • @rheras you probably have the wrong file. Check which python version you have and ensure the numbers after cp match it. And also you may need the 64-bit version instead. Once you have the correctly matched file you won't get this error.
    – rosebud
    Commented Nov 17, 2021 at 13:54
  • on step3 I cant find a similar path on my pc. I have this...C:\Users\Ricardo\AppData\Roaming\Python\Python38\site-packages. Should I create the path? Commented Jun 29, 2022 at 9:13
7

You can use conda to install fiona. This is what I did:

  1. Make a virtual environment in Anaconda Navigator and install GDAL into this environement through the GUI.
  2. Install shapely with pip install shapely
  3. install finona with conda install -c conda-forge fiona

This worked for me.

2
  • 1
    Awesome. I already had gdal installed. Only had to do fiona next but didn't work without the conda-forge channel (fiona installs shapely automatically). So, just these four lines for me after installing miniconda: conda create -n GDAL, conda activate GDAL, conda install -c conda-forge gdal, conda install -c conda-forge fiona. Important to do in a new environment as these packages are finnicky..
    – Akaisteph7
    Commented Jul 7, 2022 at 18:24
  • Yes, looking back, this is the way. Commented Jul 8, 2022 at 19:56
6

This worked for me in this exact order:

pip install pipwin
pipwin install gdal
pipwin install fiona
pip install geopandas

Everything else did not work for me. Using the wheels manually did not work because of the error:
ERROR: GDAL‑3.4.3‑pp38‑pypy38_pp73‑win_amd64.whl is not a valid wheel filename..

What is Pipwin?

pipwin is a complementary tool for pip on Windows. pipwin installs unofficial python package binaries for windows provided by Christoph Gohlke here.

1
  • Only problem with pipwin is that it also installs: pySmartDL, pyprind, pyjsparser, docopt, tzdata, pytz-deprecation-shim, tzlocal, js2py.
    – not2qubit
    Commented Jul 27, 2022 at 18:04
1

I used conda-forge to install Fiona, but if this isn't an option for you, try using pipwin instead:

pip install pipwin

pipwin install fiona

I also used pipwin install geopandas and pipwin install gdal to get those libraries imported.

0

The best way is to use pipwin for installing gdal and then fiona. Alternative option is to use pyogrio instead of fiona.

-1

You have to follow these steps:

Step One: Download GDAL from here (You should choose the package that fits your architecture, amd64 for winx64 for example, and that fits your python version, cp39 for python3.9 for example)

Step Two: Download Fiona from here

Step Three: Install both with:

pip install C:\Path\to\package.whl

Step four: pip install geopandas

3
  • 1
    Don't the existing answers already cover this? Please don't repeat answers. If this answer is somehow meaningfully better, please clearly explain how. See How to Answer.
    – Chris
    Commented Jul 11, 2022 at 22:43
  • Hi @Chris The other answer is missing some information that I consider is important. The GDAL installation is not included and it does not say which version you should include to install, that´s why I decided to join all. Commented Jul 13, 2022 at 8:28
  • 1
    There are five other answers. This one links to the same site you have linked to and also recommends installing GDAL. So does this one.
    – Chris
    Commented Jul 13, 2022 at 10:40

Not the answer you're looking for? Browse other questions tagged or ask your own question.