I'm trying to instal the GDAL python package, preferably in a virtual environment, but when I try "pip install gdal", I get the following error:

extensions/gdal_wrap.cpp:3085:10: fatal error: 'cpl_port.h' file not found
    #include "cpl_port.h"

I have GDAL version 1.11.4 installed on my Mac. I installed it via Kyngchaos, and it is located at /Library/Frameworks/GDAL.framework/Versions/1.11/Resources/gdal

the cpl_port.h file is located in /Library/Frameworks/GDAL.framework/Versions/1.11/Headers

I've read several related topics but they're all on ubuntu and using older versions of pip that have commands like "--no-install" etc.


I found the answer on another thread with some minor tweaks:

(Adapted from Yellowcap's answer)

Make a virtual environment:

virtualenv env
source env/bin/activate
cd env

Download the GDAL package version you want, unzip it and cd into it:

pip download GDAL==1.11.2 (or whichever version you want)
tar -zxvf GDAL-1.11.2.tar.gz
cd GDAL-1.11.2

According to Yellowcap, you might need:

export CFLAGS=-Qunused-arguments export CPPFLAGS=-Qunused-arguments


python setup.py build_ext\

Build and install:

python setup.py build
python setup.py install

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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