Error while installing GDAL Error while installing GDAL python python

Error while installing GDAL


Check that you installed GDAL using this command

gdal-config --version

Then run this commands:

pip download="some_path" GDALcd some_pathtar -xvzf GDAL-<version>.tar.gzcd GDAL-<version>python setup.py build_ext --include-dirs=/usr/include/gdal/python setup.py install


On my MacBook, the update/fresh install of GDAL using this approach with homebrew worked out fine. The problem on my Mac was that I apparently had an old GDAL version installed and wasn't able to update with brew upgrade gdal because of the above error message.

Solution in short:

brew unlink gdalbrew tap osgeo/osgeo4mac && brew tap --repairbrew install jasper netcdf # gdal dependenciesbrew install gdal2 --with-armadillo --with-complete --with-libkml --with-unsupportedbrew link --force gdal2

Verification:

$> gdal-config --version2.1.3$> gdal-config --libs-L/usr/local/Cellar/gdal2/2.1.3_3/lib -lgdal$> gdal-config --cflags-I/usr/local/Cellar/gdal2/2.1.3_3/include


pip install GDAL==$(gdal-config --version | awk -F'[.]' '{print $1"."$2}')

This is a copy-paste of this comment by nicerobot, that at this time received more up votes than all currently posted answers combined.

As far as I can tell, it asks pip to install the pip package of the same version as the installed gdal system package.