[gdal-dev] _gdal_array not found

Even Rouault even.rouault at mines-paris.org
Fri Oct 29 07:08:46 EDT 2010


Jorge,

WriteArray() needs the gdal-numpy module to be built. So ensure you have numpy
and numpy-devel packages installed (or whatever they are named on your distro)
when rebuilding the GDAL python bindings. I guess you lack the numpy-devel
package that is necessary for building and probably not installed if you've just
installed the packaged version.

> Hi,
>
> I'm using Python 2.7, with GDAL 1.7.2 bindings. Piece of code:
>
> (...)
> dst_ds = raster.Create( tiff, tiff_width, tiff_height, 4, gdal.GDT_Byte)
> (...)
> zeros = numpy.zeros( (tiff_height, tiff_width), numpy.uint8 )
> dst_ds.GetRasterBand(1).WriteArray( zeros )
> (...)
>
> In the "WriteArray" line, I get this exception:
>
> File "myFile.py", line 389, in createBlankRasters
>     dst_ds.GetRasterBand(1).WriteArray( zeros )
>   File "/usr/local/lib/python2.7/site-packages/osgeo/gdal.py", line
> 898, in WriteArray
>     import gdalnumeric
>   File "/usr/local/lib/python2.7/site-packages/osgeo/gdalnumeric.py",
> line 1, in <module>
>     from gdal_array import *
>   File "/usr/local/lib/python2.7/site-packages/osgeo/gdal_array.py",
> line 25, in <module>
>     _gdal_array = swig_import_helper()
>   File "/usr/local/lib/python2.7/site-packages/osgeo/gdal_array.py",
> line 17, in swig_import_helper
>     import _gdal_array
> ImportError: No module named _gdal_array
>
> Ok, the file _gdal_array.py doesn't exist. But this code works with
> Python 2.4 and GDAL 1.6.0 in the same machine (Suse Enterprise 10.2
> x86_64).
>
> Comparing the contents of the
> /usr/local/lib/python2.7/site-packages/osgeo/ directory with the
> contents of the equivalent directory of the other version of Python
> (/usr/lib/python2.4/site-packages/GDAL-1.6.0-py2.4-linux-x86_64.egg/osgeo/),
> I find several files missing in the newer one (2.7). Files like
> "_gdal_array.py", "_gdal_array.pyc", "_gdalconst.py",
> "_gdal_array.so", "_gdalconst.so", "_gdal.py", "_gdal.pyc",
> "_gdal.so", and so on. All the missing files starting with "_"
>
> The newer installation (2.7) was created from sources, building python
> 2.7 and GDAL 1.7.2 (with "configure --with-python && make && make
> install"). The previous installation (2.4) was created from package
> manager (Suse YaST).
>
> I've looking for the missing files in another directories, but they
> don't exist. I suppose they weren't compiled, but why? If they're no
> longer neded with GDAL 1.7.2, why is python 2.7 asking for them? I
> need the code to work in this new version. Any clues?
>
> Many thanks in advance,
>
> --
> Jorge Arévalo
> Internet & Mobilty Division, DEIMOS
> jorge.arevalo at deimos-space.com
> http://mobility.grupodeimos.com/
> http://gis4free.wordpress.com
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev
>




More information about the gdal-dev mailing list