Error installing geopandas:“ A GDAL API version must be specified ” in Anaconda

Posted on

Question :

Error installing geopandas:“ A GDAL API version must be specified ” in Anaconda

This error raised while installing geopandas. I’ve looking for its solution on the web, but none of them really explain what happened and how to solve it..
This is the full error:

    Collecting geopandas
  Using cached https://files.pythonhosted.org/packages/24/11/d77c157c16909bd77557d00798b05a5b6615ed60acb5900fbe6a65d35e93/geopandas-0.4.0-py2.py3-none-any.whl
Requirement already satisfied: shapely in c:usersalvaroanaconda3envstfdeeplearninglibsite-packages (from geopandas) (1.6.4.post2)
Requirement already satisfied: pandas in c:usersalvaroanaconda3envstfdeeplearninglibsite-packages (from geopandas) (0.20.3)
Collecting fiona (from geopandas)
  Using cached https://files.pythonhosted.org/packages/3a/16/84960540e9fce61d767fd2f0f1d95f4c63e99ab5d8fddc308e8b51b059b8/Fiona-1.8.4.tar.gz
    Complete output from command python setup.py egg_info:
    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.

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:UsersAlvaroAppDataLocalTemppip-install-oxgkjg8lfiona

Answer #1:

pip install wheel
pip install pipwin

pipwin install numpy
pipwin install pandas
pipwin install shapely
pipwin install gdal
pipwin install fiona
pipwin install pyproj
pipwin install six
pipwin install rtree
pipwin install geopandas

here are the source links:
http://geopandas.org/install.html#installation
https://pip.pypa.io/en/latest/user_guide/#installing-from-wheels
https://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy

If you still have problems, consider uninstalling the above (pip uninstall) and reinstalling.

Answered By: JDOaktown

Answer #2:

Geospatial Data Abstraction Library (GDAL) is a library designed for vector geospatial data formats. It’s a prerequisite for installing Fiona, the Python API for OGR (which doesn’t really stand for anything), which is in turn a prerequisite for Geopandas. On UNIX-like systems the gdal-config script tells Fiona stuff about your particular gdal installation.

It seems that your gdal-config is not in one of the usual places on your PATH, so Fiona was unable to find it.

If you’re using Anaconda, best is to remove gdal with conda remove gdal and then do a fresh conda install geopandas.

As a general rule, if you’re using Conda you should never use pip to install something inside it unless you’re absolutely sure conda offers no support for it. (Many package can be found on conda by specifying the right channel – -c argument.) And specifically in the case of geopandas, the maintainers recommend using conda over pip, since pip requires you to install the dependencies correctly.

Answered By: Josh Friedlander

Answer #3:

I had a lot of issues myself installing geopandas, mostly showing error when downloading fiona and gdal. I did every step above and did a conda install geopandas but failed. The only thing worked for me is to install fiona and gdal wheel separately.

go to the link by Christoph: gohlke:https://www.lfd.uci.edu/~gohlke/pythonlibs/#fiona

  • You can search for fiona and gdal wheel files. Make sure you choose the file as per your python version, if it is 3.7 then there would be cp37.
  • Download the file
  • go to command prompt, put cd and then pip install , install GDAL wheel file, then fiona, then just do pip install geopandas.

This solution worked for me.

Answered By: aryastark

Answer #4:

One way in which I could install geopandas was through the Anaconda Navigator. Get into the environment and install the package ‘geopandas’. After that I could import the geopandas package in spyder

Answered By: Devarshi Mandal

Answer #5:

To install gdal, I followed the following steps:

  1. downloaded the version that satisfies my computer (64 bit) from
    https://www.lfd.uci.edu/~gohlke/pythonlibs/ . The file was GDAL-3.1.4-cp37-cp37m-win_amd64.whl

  2. Put the file in a folder on the desktop.

  3. From cmd, i moved to that directory and executed python -m pip install GDAL-3.1.4-cp37-cp37m-win_amd64.whl

  4. This is followed by installing fiona the same way: python -m pip install Fiona-1.8.18-cp37-cp37m-win_amd64.whl

  5. For shapely, i executed conda install -c conda-forge shapely

  6. After that, i was able to install keplergl as usual: pip install keplergl

  7. install descartes: conda install -c conda-forge descartes (or python -m pip install descartes).

In this way, i didn’t have to play around with the ‘Environmental Variables’ as this may affect other programs
Cheers..

Answered By: Taie

Answer #6:

I will add

!pip install descartes

to @JDOaktown list.

Answered By: Zeinab Sobhani

Answer #7:

I solved this problem by running the following commands:

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

This solution is tested and worked successfully just on the Windows platform.

Answer #8:

I started with pip install geopandas and got the error, but later tried with conda install --channel conda-forge geopandas and the error disappeared.

Answered By: Max

Leave a Reply

Your email address will not be published. Required fields are marked *