I'm trying to install GDAL on a Mac (macos 10.12.2). I downloaded the GDAL 2.1 Complete package from http://www.kyngchaos.com/software/frameworks (which installs GDAL 2.1.2), and successfully ran the installer. Now I'm trying to compile the Python bindings, using pip. In my bash_profile, I added lines for include paths (where the GDAL installer put them):

export CPLUS_INCLUDE_PATH=/Library/Frameworks/GDAL.framework/Versions/2.1/Headers
export C_INCLUDE_PATH==/Library/Frameworks/GDAL.framework/Versions/2.1/Headers
export LIBRARY_PATH=/Library/Frameworks/GDAL.framework/Versions/2.1/unix/lib

then I tried to compile the bindings with:

pip install gdal==2.1.2

but pip complained it could only find versions up to 2.1.0 ("No matching distribution found for gdal==2.1.2"). So I tried using 2.1.0 for the install:

pip install gdal==2.1.0

which got pip to attempt the install, but which eventually failed with:

fatal error: 'gdal.h' file not found
  #include "gdal.h"
 2 warnings and 1 error generated.
 error: command '/usr/bin/clang' failed with exit status 1

Yet, the file gdal.h is located in the Header directory I set for my include paths.

I tried the advice given in the following questions:

Python GDAL package missing header file when installing via pip

Install GDAL python package in virtualenv on mac

but it did not fix my problem.

What should I do next?

  • According to your link, the GDAL framework includes the python bindings. So why try to install them separately via pip?
    – user2856
    Dec 17, 2016 at 9:27
  • I'm following Westra 2016 link, which says binding is a separate step in the installation process. Also, when I tried to import the osgeo module (part of GDAL complete), the shell reported it as not found, which seemed to confirm that it was not bound to Python. Dec 17, 2016 at 15:06

1 Answer 1


As Luke says, the Python bindings are included in the GDAL Framework (you can use Suspicious Package, free, or Pacifist, shareware, to examine the content of the GDAL 2.1 Complete package)

enter image description here

And there is gdal-py2.7.pth path file witch is installed in a in the Apple Python site-packages folder and points to the precedent folder (/Library/Python/2.7/site-packages/gdal-py2.7.pth)

enter image description here

But there is a problem: the content of this file is

import sys; sys.path.insert(0,'/Library/Frameworks/GDAL.framework/Versions/1.11/Python/2.7/site-packages')

though it should be

import sys; sys.path.insert(0,'/Library/Frameworks/GDAL.framework/Versions/2.1/Python/2.7/site-packages')

Therefore, simply correct the gdal-py2.7.pth file.

Now if you want to compile yourself the Python bindings, download the GDAL 2.1.0 python module and

python setup.py build_ext -I/Library/Frameworks/GDAL.framework/Versions/2.1/Headers -L/Library/Frameworks/GDAL.framework/Versions/2.1/unix/lib -lgdal
python setup.py build
python setup.py install

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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