#6801 closed defect (fixed)
python3-gdal: ImportError: No module named '_gdal_array'
Reported by: | Bas Couwenberg | Owned by: | hobu |
---|---|---|---|
Priority: | normal | Milestone: | 2.1.4 |
Component: | PythonBindings | Version: | 2.1.2 |
Severity: | normal | Keywords: | |
Cc: | Bas Couwenberg |
Description
As reported by Teemu Ikonen in Debian Bug #853900:
Trying to import osgeo.gdal_array module results in this:
$ python3 -c "import osgeo.gdal_array" Traceback (most recent call last): File "<string>", line 1, in <module> File "/usr/lib/python3/dist-packages/osgeo/gdal_array.py", line 168, in <module> import _gdal_array ImportError: No module named '_gdal_array'
With the following changes the import error is fixed:
--- /usr/lib/python3/dist-packages/osgeo/gdal_array.py.bak 2017-02-01 23:04:50.776314931 +0100 +++ /usr/lib/python3/dist-packages/osgeo/gdal_array.py 2017-02-01 23:05:07.052629725 +0100 @@ -165,7 +165,7 @@ return _gdal_array.RATValuesIONumPyRead(poRAT, nField, nStart, nLength) import numpy -import _gdal_array +from . import _gdal_array from . import gdalconst from . import gdal
Since gdal_array.py
is generated by SWIG, swig/include/gdal_array.i
should probably be modified instead, but that code already gets rewritten by SWIG:
996 import numpy 997 import _gdal_array 998 999 import gdalconst 1000 import gdal
Is there some way to fix the SWIG interface file to have it converted properly for Python 3, or is this simply a bug in SWIG (3.0.10 is used)?
Change History (4)
comment:1 by , 8 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:3 by , 8 years ago
I could indeed reproduce the issue with SWIG 3.0.10 but not with SWIG 3.0.8. I've fixed a push that seems to work OK with Python2/Python3 + SWIG 3.0.8/3.0.10 combinations
comment:4 by , 8 years ago
Thanks for the fixes, I'll included them as a patch in the Debian package.
In 37276: