[gdal-dev] ModuleNotFoundError: No module named 'osgeo._gdal_array'

Even Rouault even.rouault at spatialys.com
Fri Sep 24 06:14:24 PDT 2021


Lorenzo,

you didn't mention which Linux distro you used and how you installed numpy

I'm aware at least that on Alpine Linux, you need to install an 
additional py3-numpy-dev package with the headers & lib needed to use 
the C API of numpy, which is needed by the GDAL Python bindings

Check that the following returns something sensible

python3 -c "import numpy; print(numpy.get_include())"

when you build the GDAL python bindings look for the following messages 
in the output that will indicate that the gdal_array module can't be built

"WARNING: numpy headers were not found!  Array support will not be enabled"

or

'WARNING: numpy not available!  Array support will not be enabled'

Even

Le 24/09/2021 à 14:53, Lorenzo Di Giacomo a écrit :
> Hi everyone, basically i build from source GDAL 3.2.2 and install the 
> python bindings via pip3 install gdal==3.2.2
>
> Later i install numpy, i have read online that the numpy must be 
> installed before GDAL python bindings.
> So i tried to uninstall python gdal and than reinstall it, but the 
> problem still persists.
>
> Do you have any suggestions about it?
>
> Python3 libraries:
> GDAL 3.2.2
> NUMPY 1.21.2
>
> SWIG 4.0.2
>
> LOG:
> ModuleNotFoundError: No module named 'osgeo._gdal_array'
>
> During handling of the above exception, another exception occurred:
>
> Traceback (most recent call last):
>    File "temp-1544239507789228725main.py", line 98, in <module>
>      SSRD,gtSSRD = tiff2array(path_to_tiff, band_SSRD)
>    File "/hadoop/yarn/local/usercache/dispatcher/appcache/application_1628674283442_0030/container_e33_1628674283442_0030_01_000001/61a5101c-d78d-494d-b0d6-ef16719143719035222534140350861632485975806.zip/utility/rasterutils.py", line 58, in tiff2array
>    File "/usr/local/lib/python3.7/site-packages/osgeo/gdal.py", line 3832, in ReadAsArray
>      from osgeo import gdalnumeric
>    File "/usr/local/lib/python3.7/site-packages/osgeo/gdalnumeric.py", line 2, in <module>
>      from osgeo.gdal_array import *
>    File "/usr/local/lib/python3.7/site-packages/osgeo/gdal_array.py", line 17, in <module>
>      _gdal_array = swig_import_helper()
>    File "/usr/local/lib/python3.7/site-packages/osgeo/gdal_array.py", line 16, in swig_import_helper
>      return importlib.import_module('_gdal_array')
>    File "/usr/local/lib/python3.7/importlib/__init__.py", line 127, in import_module
>      return _bootstrap._gcd_import(name[level:], package, level)
> ModuleNotFoundError: No module named '_gdal_array'
>
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/gdal-dev

-- 
http://www.spatialys.com
My software is free, but my time generally not.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20210924/3d166120/attachment-0001.html>


More information about the gdal-dev mailing list