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

Even Rouault even.rouault at spatialys.com
Wed Jan 28 09:53:16 PST 2015


Le mercredi 28 janvier 2015 18:51:28, Jorge Arévalo a écrit :
> Hi,
> 
> > Even Rouault <mailto:even.rouault at spatialys.com>
> > January 28, 2015 at 6:44 PM
> > 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...
> 
> Yes, I felt the pain of python bindings don't honouring the --prefix
> specified... Good to know there's a debate on this.
> 
> Sorry about my vague description. I just did it using sudo, for a system
> installation, and after that, system Python still didn't find the path.
> So, after
> 
> sudo python gdal_sources/swig/python/setup.py install
> 
> I still get the same error:
> 
> ImportError: no module named _gdal_array

Are you sure you don't have a python-gdal package hanging somewhere ? (but 
that would be weird it wouldn't have numpy support). Or a custom python-gdal 
bindings installed in another location that is tried before the one where you 
install.

> 
> >> 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.
> 
> Yep, that was what I thought. But still fails after sudo make install.
> The only way I've found to make it work is by exporting PYTHONPATH
> 
> Best regards,
> 
> Jorge
> 
> >> 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