-3

I ran into this problem while trying to install geopandas using this command in the command prompt. "pip install geopandas"

This is the error message I got.

C:\WINDOWS\system32>pip install geopandas 
Collecting geopandas
Using cached geopandas-0.11.1-py3-none-any.whl (1.0 MB)                                                               
Requirement already satisfied: packaging in 
c:\users\sasika\appdata\roaming\python\python38\site-packages (from geopandas) (21.3)                                                                                                               
Collecting fiona>=1.8                                                                                                     
Using cached Fiona-1.8.21.tar.gz (1.0 MB)                                                                               
Preparing metadata (setup.py) ... error                                                                                 
error: subprocess-exited-with-error                                                                                                                                                                                                             
× python setup.py egg_info did not run successfully.                                                                    
│ exit code: 1                                                                                                          
╰─> [1 lines of output]                                                                                                     
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.                                                                                        
[end of output]                                                                                                                                                                                                                             
note: This error originates from a subprocess, and is likely not a problem with pip.                                  
error: metadata-generation-failed                                                                                                                                                                                                               
× Encountered error while generating package metadata.                                                                  
╰─> See above for output.                                                                                                                                                                                                                       
note: This is an issue with the package mentioned above, not pip.                                                       
hint: See above for details.

Thank you so much in advance!

SasikaA
  • 11
  • 3
  • 3
    I'd suggest reading the error message and googling the specific error you're getting. – Filip Müller Aug 14 '22 at 17:41
  • 1
    Does this answer your question? [Error installing geopandas:" A GDAL API version must be specified " in Anaconda](https://stackoverflow.com/questions/54734667/error-installing-geopandas-a-gdal-api-version-must-be-specified-in-anaconda) – Michael Delgado Aug 14 '22 at 18:42
  • 1
    see also this: https://stackoverflow.com/questions/73238923/problem-while-installing-geopandas-with-conda – Michael Delgado Aug 14 '22 at 18:43

2 Answers2

2

Pip is good for some simple installation tasks, such as pure-python installs. If complex binary deps are getting you down, a more sophisticated tool would be a better match for your needs.

Create / activate an empty conda environment, and then follow the install instructions:

$ conda install -c conda-forge geopandas
J_H
  • 17,926
  • 4
  • 24
  • 44
  • if you do this, don't install anaconda. instead, install [`miniforge`](https://github.com/conda-forge/miniforge#miniforge) and create an environment when you install geopandas – Michael Delgado Aug 14 '22 at 18:44
0

I tried this command first, but it did take some time to execute. $ conda install -c conda-forge geopandas So, I cancelled the batch job of that command.

Then, made a python environment and activated it

$ python -m venv maps
$ cd maps\scripts
$ activate 
$ cd ..
$ cd ..

Then made 'requirements.txt' file including these python libraries.

numpy 
pandas 
shapely 
gdal 
fiona 
pyproj 
six 
rtree 

then ran these commands in order. 'maps' is the python environment,in my case.

(maps) $ pip install wheel
(maps) $ pip install pipwin
(maps) $ pipwin install -r requirements.txt
(maps) $ pip install geopandas

This worked successfully.

SasikaA
  • 11
  • 3
  • Initially, I had included 'geopandas' in the requirements.txt. But it gave me this error. ``` Package `geopandas` not found Try `pipwin refresh` ``` Even after, refreshing the pipwin , I got the same error message. Then installed 'geopandas' separately using 'pip' instead of 'pipwin' – SasikaA Aug 15 '22 at 15:56
  • I'd strongly recommend using conda to install geopandas. pip does not do a good job managing non-python dependencies. Even if you get this running first time around, maintaining this will be a real challenge. If the runtime of conda is too slow, try [`mambaforge`](https://github.com/conda-forge/miniforge#mambaforge). It's a (much) faster, multithreaded port of conda written in C++. – Michael Delgado Aug 15 '22 at 16:50