<html><head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head><body text="#000000" bgcolor="#FFFFFF"><br>
<br>
<blockquote style="border: 0px none;"
cite="mid:201501281853.16817.even.rouault@spatialys.com" type="cite">
<div style="margin:30px 25px 10px 25px;" class="__pbConvHr"><div
style="display:table;width:100%;border-top:1px solid
#EDEEF0;padding-top:5px"> <div
style="display:table-cell;vertical-align:middle;padding-right:6px;"><img
photoaddress="even.rouault@spatialys.com" photoname="Even Rouault"
src="cid:part1.07020301.06020605@cartodb.com"
name="compose-unknown-contact.jpg" width="25px" height="25px"></div> <div
style="display:table-cell;white-space:nowrap;vertical-align:middle;width:100%">
<a moz-do-not-send="true" href="mailto:even.rouault@spatialys.com"
style="color:#737F92
!important;padding-right:6px;font-weight:bold;text-decoration:none
!important;">Even Rouault</a></div> <div
style="display:table-cell;white-space:nowrap;vertical-align:middle;">
<font color="#9FA2A5"><span style="padding-left:6px">January 28, 2015
at 6:53 PM</span></font></div></div></div>
<div style="color: rgb(136, 136, 136); margin-left: 24px;
margin-right: 24px;" __pbrmquotes="true" class="__pbConvBody"><pre wrap="">Le mercredi 28 janvier 2015 18:51:28, Jorge Arévalo a écrit :
</pre><blockquote type="cite"><pre wrap="">Hi,
</pre><blockquote type="cite"><pre wrap="">Even Rouault <a class="moz-txt-link-rfc2396E" href="mailto:even.rouault@spatialys.com"><mailto:even.rouault@spatialys.com></a>
January 28, 2015 at 6:44 PM
Jorge,
</pre><blockquote type="cite"><pre wrap="">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.
</pre></blockquote><pre wrap="">"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...
</pre></blockquote><pre wrap="">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
</pre></blockquote><pre wrap=""><!---->
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.
</pre></div>
</blockquote>
Yep. Looked for gdal packages:<br>
<br>
dpkg-query --show --showformat='${Package;-50}\t${Installed-Size}\n' |
sort -k 2 -n | grep -v deinstall | awk '{printf "%.3f MB \t %s\n",
$2/(1024), $1}' | grep gdal<br>
<br>
0 found. Just installed GDAL from sources, using this line<br>
<br>
./configure --with-python --without-libtool
--with-curl=/usr/bin/curl-config<br>
<br>
Also looked for any existent gdal_array.py<br>
<br>
sudo find / -name gdal_array.py<br>
<br>
Just found the one in my sources tree, and the system one at
/usr/local/lib/python2.7/dist-packages/osgeo/gdal_array.py. <br>
<br>
If I print sys.path from Python console, I get:<br>
<br>
['', '/home/jorge', '/usr/lib/python2.7',
'/usr/lib/python2.7/plat-x86_64-linux-gnu', '/usr/lib/python2.7/lib-tk',
'/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload',
'/usr/local/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages/PILcompat']<br>
<br>
So, <span>/usr/local/lib/python2.7/dist-packages is included, but </span><span>/usr/local/lib/python2.7/dist-packages/osgeo
doesn't. I tried with<br>
<br>
from osgeo import gdal_array<br>
<br>
And then, I get ImportError: no module named _gdal</span><br>
<blockquote style="border: 0px none;"
cite="mid:201501281853.16817.even.rouault@spatialys.com" type="cite">
<div style="color:#888888;margin-left:24px;margin-right:24px;"
__pbrmquotes="true" class="__pbConvBody">
<pre wrap="">
</pre>
<blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><pre wrap="">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?
</pre></blockquote><pre wrap="">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.
</pre></blockquote><pre wrap="">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
</pre><blockquote type="cite"><blockquote type="cite"><pre wrap="">Am I doing something wrong?
Environment: Ubuntu 14.10, GDAL from trunk, Python 2.7.8
</pre></blockquote><pre wrap="">Even
</pre></blockquote></blockquote><pre wrap=""><!---->
</pre></div>
<div style="margin:30px 25px 10px 25px;" class="__pbConvHr"><div
style="display:table;width:100%;border-top:1px solid
#EDEEF0;padding-top:5px"> <div
style="display:table-cell;vertical-align:middle;padding-right:6px;"><img
photoaddress="even.rouault@spatialys.com" photoname="Even Rouault"
src="cid:part1.07020301.06020605@cartodb.com"
name="compose-unknown-contact.jpg" width="25px" height="25px"></div> <div
style="display:table-cell;white-space:nowrap;vertical-align:middle;width:100%">
<a moz-do-not-send="true" href="mailto:even.rouault@spatialys.com"
style="color:#737F92
!important;padding-right:6px;font-weight:bold;text-decoration:none
!important;">Even Rouault</a></div> <div
style="display:table-cell;white-space:nowrap;vertical-align:middle;">
<font color="#9FA2A5"><span style="padding-left:6px">January 28, 2015
at 6:44 PM</span></font></div></div></div>
<div style="color:#888888;margin-left:24px;margin-right:24px;"
__pbrmquotes="true" class="__pbConvBody"><pre wrap="">Jorge,
</pre><blockquote type="cite"><pre wrap="">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.
</pre></blockquote><pre wrap=""><!---->
"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...
</pre><blockquote type="cite"><pre wrap="">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?
</pre></blockquote><pre wrap=""><!---->
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.
</pre><blockquote type="cite"><pre wrap="">Am I doing something wrong?
Environment: Ubuntu 14.10, GDAL from trunk, Python 2.7.8
</pre></blockquote><pre wrap=""><!---->
Even
</pre></div>
</blockquote>
<br>
<div class="moz-signature">-- <br>
<div>Sent with <a href="http://www.getpostbox.com"><span style="color:
rgb(51, 102, 153);">Postbox</span></a></div></div>
</body></html>