[gdal-dev] Python installation can't find gdal_array.py

Even Rouault even.rouault at spatialys.com
Wed Jan 28 09:44:43 PST 2015


Jorge,

> 
> I've compiled GDAL from trunk, specifying --with-python at configure
> time. I first checked numpy is correctly installed. The problem is I
> couldn't import gdal_array.py by default (got ImportError: no module
> named _gdal_array).
> 
> Tried
> 
> python gdal_sources/swig/python/setup.py install
> 
> Didn't work.

"didn't work", could you be more precise ?
"python setup.py install" requires root rights since it installs in 
/usr/local/lib. There's a ticket&debate if the python bindings should honour 
the --prefix specified at configure time or not. Currently they don't, and it is 
an annoyance for folks. Perhaps we should revert to honour the prefix, but this 
was disabled at some point and nobody remembers why...

> 
> I finally had to define
> 
> export PYTHONPATH=$PYTHONPATH:$/usr/local/lib/python2.7/dist-packages/osgeo
> 
> to make it work. And I don't think that's the default solution, right?

That's what I use since I have many GDAL versions on my machine and must 
switch between them without reinstalling. For regular users not tweaking the 
installation prefix, "sudo make install" should do the right thing however.

> Am I doing something wrong?
> 
> Environment: Ubuntu 14.10, GDAL from trunk, Python 2.7.8
> 

Even

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com


More information about the gdal-dev mailing list