I am trying to install fiona
and geopandas
on a mac machine.
I have installed GDAL
trough brew install gdal --HEAD
If I try install fiona
, I get the following:
sudo pip3 install fiona
Collecting fiona
Downloading Fiona-1.8.18.tar.gz (1.3 MB)
|████████████████████████████████| 1.3 MB 4.7 MB/s
ERROR: Command errored out with exit status 1:
command: /usr/local/opt/[email protected]/bin/python3.9 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/tmp/pip-install-sk0rqerp/fiona_e389978ed5a44635a5158a0ba3df8562/setup.py'"'"'; __file__='"'"'/private/tmp/pip-install-sk0rqerp/fiona_e389978ed5a44635a5158a0ba3df8562/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 /private/tmp/pip-pip-egg-info-bngdnoq7
cwd: /private/tmp/pip-install-sk0rqerp/fiona_e389978ed5a44635a5158a0ba3df8562/
Complete output (2 lines):
Failed to get options via gdal-config: [Errno 2] No such file or directory: 'gdal-config'
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.
Make sure you choose the file as per your python version, if it is 3.7 then there would be cp37. go to command prompt, put cd and then pip install , install GDAL wheel file, then fiona, then just do pip install geopandas.
It could be that the gdal-config program isn't in your path when you're SUDO'ed. The root user may not have /usr/local/bin in the path, so when you execute the command with SUDO, it fails to find the command in the path, but when you do it with your 'regular' user, it finds it.
In ubuntu, a simpler solution to install the latest gdal for python3: install library files via libgdal-dev, and python wrapper via python-gdal You may also encounter problem whith memory usage. When running pip install gdal==2.2.3 gcc is launch to compile something and it raises memory usage.
However GDAL is installed correctly and the header file is located at /usr/include/gdal/cpl_port.h. Is there some environment variable for GDAL that needs to be set in order for pip to find the header files? selimnairb's answer is close but you wont have the headers unless you've installed libgdal-dev:
Each gdal version might assume different version of GDAL and will fail installing if expected version is not present in the system. Python package pygdal is alternative to gdal, which installs exactly the same stuff as gdal, but does it in much more virtualenv friendly manner. pygdal comes in versions reflecting related GDAL version.
This problem occured for me when trying to install geopandas on a M1 Mac (using the command pip3 install geopandas
)
Using homebrew package manager, install the gdal
package:
brew install gdal
Then try again installing the failed pip install:
pip3 install geopandas
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With