0

I have a Centos 6.6 VM with the Python 2.7 SCL. I have gdal and gdal-devel installed.

If I start the scl with sudo scl enable python27 bash and do a pip install gdal it fails on:

gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I../../port -I../../gcore -I../../alg -I../../ogr/ -I/opt/rh/python27/root/usr/include/python2.7 -I. -I/usr/include -c extensions/gdal_wrap.cpp -o build/temp.linux-x86_64-2.7/extensions/gdal_wrap.o

extensions/gdal_wrap.cpp:2855:22: error: cpl_port.h: No such file or directory

extensions/gdal_wrap.cpp:2856:24: error: cpl_string.h: No such file or directory

extensions/gdal_wrap.cpp:2857:27: error: cpl_multiproc.h: No such file or directory

extensions/gdal_wrap.cpp:2858:22: error: cpl_http.h: No such file or directory

extensions/gdal_wrap.cpp:2860:18: error: gdal.h: No such file or directory

extensions/gdal_wrap.cpp:2861:23: error: gdal_priv.h: No such file or directory

extensions/gdal_wrap.cpp:2862:22: error: gdal_alg.h: No such file or directory

extensions/gdal_wrap.cpp:2863:24: error: gdalwarper.h: No such file or directory

extensions/gdal_wrap.cpp:4870:22: error: gdalgrid.h: No such file or directory

extensions/gdal_wrap.cpp:2880: error: ‘CPLErrorHandler’ does not name a type

extensions/gdal_wrap.cpp:2883: error: expected initializer before ‘PythonBindingErrorHandler’

extensions/gdal_wrap.cpp:2755: warning: ‘swig_module’ defined but not used

error: command 'gcc' failed with exit status 1

What's the right way to get gdal in /opt/rh/python27/root/usr/include/ or make pip point gcc to /usr/include/?

1 Answer 1

0

I got this working in a virtual environment by modifying this method.

There were two issues. First I had to specifically use the gdal module version 1.9.1. 1.10.0 and 1.11.0 will not work with version 1.9.2 of the core gdal library, which is what redhat ships with. Secondly I had to pass -I/usr/include/gdal to gcc. The sequence is as follows:

# you might need to do a sudo -s if your virtualenv is owned by root.
scl enable python27 bash
cd $VIRTUENV_ROOT
source bin/activate
pip install --no-install gdal==1.9.1
cd build/gdal
python setup.py build_ext \
  --gdal-config=/usr/bin/gdal-config \
  --include-dirs=/usr/include/gdal/
python setup.py install

A virtual environment isn't strictly necessary, but I don't know where the global python build folder is.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .