On Sat, 15 Apr 2017, Roxana Tesileanu wrote:
Hi!
I'm trying to access GDAL in Python and tried "sudo pip install GDAL". But an
error comes out. I've downloaded also the packege from the GDAL website but
still doesn't work. Could you please help me out? Many thanks! Roxana
I use gdal on SL6 not SL7, don't use python much and pip not at all,
but I'll ty to help.
Where did you get gdal from -
rpmquery -i gdal
might say, if you don't know.
The cpl_port.h missing error suggests that pip assumes
you already have gdal installed (in the place it is looking
and probably the expected version).
Since you do have gdalinfo installed I guess that pip isn't
looking for cpl_port.h in the right place; mine is at
/usr/include/gdal/cpl_port.h
but I think from the exact error below that pip expects it at
/usr/include/cpl_port.h
while there various ways of hacking a solution to this
specific error, I'd expect they would only lead to
the real issue causing more errors.
My guess that you have installed gdal from epel,
but not the gdal-python package that goes with it.
Could you try
sudo yum --enablerepo=epel install gdal-python
?
PS: Here is the output from the Terminal:
[rtesileanu@localhost ~]$ gdalinfo --version
GDAL 1.11.4, released 2016/01/25
[rtesileanu@localhost ~]$ sudo pip install GDAL=1.11.4
[sudo] password for rtesileanu:
Invalid requirement: 'GDAL=1.11.4'
= is not a valid operator. Did you mean == ?
[rtesileanu@localhost ~]$ sudo pip install GDAL==1.11.4
Collecting GDAL==1.11.4
Could not find a version that satisfies the requirement GDAL==1.11.4 (from
versions: 1.5.0, 1.5.2, 1.6.0, 1.6.1, 1.7.0, 1.7.1, 1.8.1, 1.9.0, 1.9.1,
1.10.0, 1.11.0, 1.11.1, 1.11.2, 2.0.0, 2.0.1, 2.1.0, 2.1.3)
No matching distribution found for GDAL==1.11.4
[rtesileanu@localhost ~]$ sudo pip install GDAL==2.1.3
Collecting GDAL==2.1.3
Using cached GDAL-2.1.3.tar.gz
Installing collected packages: GDAL
Running setup.py install for GDAL ... error
Complete output from command /usr/bin/python2 -u -c "import setuptools,
tokenize;__file__='/tmp/pip-build-9uzTW8/GDAL/setup.py';f=getattr(tokenize,
'open', open)(__file__);code=f.read().replace('\r\n',
'\n');f.close();exec(compile(code, __file__, 'exec'))" install --record
/tmp/pip-JC4z_K-record/install-record.txt --single-version-externally-managed
--compile:
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-2.7
copying gdal.py -> build/lib.linux-x86_64-2.7
copying ogr.py -> build/lib.linux-x86_64-2.7
copying osr.py -> build/lib.linux-x86_64-2.7
copying gdalconst.py -> build/lib.linux-x86_64-2.7
copying gdalnumeric.py -> build/lib.linux-x86_64-2.7
creating build/lib.linux-x86_64-2.7/osgeo
copying osgeo/gdalnumeric.py -> build/lib.linux-x86_64-2.7/osgeo
copying osgeo/gnm.py -> build/lib.linux-x86_64-2.7/osgeo
copying osgeo/gdal_array.py -> build/lib.linux-x86_64-2.7/osgeo
copying osgeo/gdalconst.py -> build/lib.linux-x86_64-2.7/osgeo
copying osgeo/__init__.py -> build/lib.linux-x86_64-2.7/osgeo
copying osgeo/ogr.py -> build/lib.linux-x86_64-2.7/osgeo
copying osgeo/osr.py -> build/lib.linux-x86_64-2.7/osgeo
copying osgeo/gdal.py -> build/lib.linux-x86_64-2.7/osgeo
running build_ext
building 'osgeo._gdal' extension
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/extensions
gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall
-Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong
--param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic
-D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall
-Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong
--param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic
-D_GNU_SOURCE -fPIC -fwrapv -fPIC -I../../port -I../../gcore -I../../alg
-I../../ogr/ -I../../ogr/ogrsf_frmts -I../../gnm -I../../apps
-I/usr/include/python2.7
-I/usr/lib64/python2.7/site-packages/numpy/core/include -I/usr/include -c
extensions/gdal_wrap.cpp -o
build/temp.linux-x86_64-2.7/extensions/gdal_wrap.o
extensions/gdal_wrap.cpp:3085:22: fatal error: cpl_port.h: No such file
or directory
#include "cpl_port.h"
^
compilation terminated.
error: command 'gcc' failed with exit status 1
----------------------------------------
Command "/usr/bin/python2 -u -c "import setuptools,
tokenize;__file__='/tmp/pip-build-9uzTW8/GDAL/setup.py';f=getattr(tokenize,
'open', open)(__file__);code=f.read().replace('\r\n',
'\n');f.close();exec(compile(code, __file__, 'exec'))" install --record
/tmp/pip-JC4z_K-record/install-record.txt --single-version-externally-managed
--compile" failed with error code 1 in /tmp/pip-build-9uzTW8/GDAL/