I'm trying to install gdal from pip pip install gdal
inside a virtual environment (Ubuntu). It fails because it cannot find cpl_port.h
extensions/gdal_wrap.cpp:2853:22: fatal error: cpl_port.h: No such file or directory
compilation terminated
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?
Using PIP :
Then cd into ENV/build/GDAL
(Source: http://ubuntuforums.org/showthread.php?t=1769445)
Using Buildout :
As suggested in the other thread, exporting some shell variables before running pip worked flawlessly. A path for
*_INCLUDE_PATH
can be found withgdal-config --cflags
.I was also getting this error when test installing in a virtual environment a package of mine that depends on GDAL. In this case the solution is to change the dependecy from
GDAL
topygdal
in theinstall_requires
parameter insetup.py
. Like so:install_requires=['pygdal'],
This is what worked for me:
I had to get the latest hearder versions for installing gdal 2.2.4 through pip:
Before that, I was getting
extensions/gdal_wrap.cpp:3172:27: fatal error: cpl_vsi_error.h: No such file or directory
, even when including the correct "include" path to pip.The the pip installation (in a virtualenv):
Tomyun's answer worked for me, with the proviso that you have to ensure that the version of GDAL-dev installed via
apt-get
matches the version being installed bypip
.For Ubuntu 14.04, the commands are:
try to do: brew install gdal
after that try again.