Installation error in linux: ModuleNotFoundError: No module named '_gdal_array'
Using Pop!_OS 20.04 (based on ubuntu 20.04) I’ve followed the web instructions:
pip3 install -r https://bitbucket.org/hu-geomatics/enmap-box/raw/develop/requirements.txt
and no errors were reported
(I note that packages were installed in home/alobo/.local/bin (which I have in my PATH)
But the installing in qgis I get:
Couldn't load plugin 'enmapboxplugin' due to an error when calling its classFactory() method
ModuleNotFoundError: No module named '_gdal_array'
Traceback (most recent call last):
File "/app/lib/python3.8/site-packages/osgeo/gdal_array.py", line 14, in swig_import_helper
return importlib.import_module(mname)
File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1014, in _gcd_import
File "", line 991, in _find_and_load
File "", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'osgeo._gdal_array'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/app/share/qgis/python/qgis/utils.py", line 334, in _startPlugin
plugins[packageName] = package.classFactory(iface)
File "/home/alobo/.var/app/org.qgis.qgis/data/QGIS/QGIS3/profiles/default/python/plugins/enmapboxplugin/__init__.py", line 47, in classFactory
raise ex
File "/home/alobo/.var/app/org.qgis.qgis/data/QGIS/QGIS3/profiles/default/python/plugins/enmapboxplugin/__init__.py", line 42, in classFactory
from enmapbox.enmapboxplugin import EnMAPBoxPlugin
File "/app/share/qgis/python/qgis/utils.py", line 793, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
File "/home/alobo/.var/app/org.qgis.qgis/data/QGIS/QGIS3/profiles/default/python/plugins/enmapboxplugin/enmapbox/__init__.py", line 425, in
initEnMAPBoxResources()
File "/home/alobo/.var/app/org.qgis.qgis/data/QGIS/QGIS3/profiles/default/python/plugins/enmapboxplugin/enmapbox/__init__.py", line 232, in initEnMAPBoxResources
from .externals.qps.resources import initQtResources, initResourceFile
File "/app/share/qgis/python/qgis/utils.py", line 793, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
File "/home/alobo/.var/app/org.qgis.qgis/data/QGIS/QGIS3/profiles/default/python/plugins/enmapboxplugin/enmapbox/externals/qps/resources.py", line 41, in
from .utils import file_search, findUpwardPath
File "/app/share/qgis/python/qgis/utils.py", line 793, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
File "/home/alobo/.var/app/org.qgis.qgis/data/QGIS/QGIS3/profiles/default/python/plugins/enmapboxplugin/enmapbox/externals/qps/utils.py", line 60, in
from osgeo import gdal, ogr, osr, gdal_array
File "/app/share/qgis/python/qgis/utils.py", line 793, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
File "/app/lib/python3.8/site-packages/osgeo/gdal_array.py", line 17, in
_gdal_array = swig_import_helper()
File "/app/lib/python3.8/site-packages/osgeo/gdal_array.py", line 16, in swig_import_helper
return importlib.import_module('_gdal_array')
File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named '_gdal_array'
Python version: 3.8.8 (default, Nov 10 2011, 15:00:00) [GCC 10.2.0]
QGIS version: 3.16.7-Hannover Hannover, 04717438
Python Path:
- /app/share/qgis/python
- /home/alobo/.var/app/org.qgis.qgis/data/QGIS/QGIS3/profiles/default/python
- /home/alobo/.var/app/org.qgis.qgis/data/QGIS/QGIS3/profiles/default/python/plugins
- /app/share/qgis/python/plugins
- /usr/lib/python38.zip
- /usr/lib/python3.8
- /usr/lib/python3.8/lib-dynload
- /usr/lib/python3.8/site-packages
- /app/lib/python3.8/site-packages
- /app/lib/python3.8/site-packages/numpy-1.19.5-py3.8-linux-x86_64.egg
- /app/lib/python3.8/site-packages/MarkupSafe-1.1.1-py3.8-linux-x86_64.egg
- /home/alobo/.var/app/org.qgis.qgis/data/QGIS/QGIS3/profiles/default/python
- /home/alobo/.var/app/org.qgis.qgis/data/QGIS/QGIS3/profiles/default/python/plugins/enmapboxplugin/site-packages
- /home/alobo/.var/app/org.qgis.qgis/data/QGIS/QGIS3/profiles/default/python/plugins/enmapboxplugin/enmapbox/externals/qps/externals
- /home/alobo/.var/app/org.qgis.qgis/data/QGIS/QGIS3/profiles/default/python/plugins/enmapboxplugin/site-packages
I also check in the qgis python console:
import scipy
Traceback (most recent call last):
File "/usr/lib/python3.8/code.py", line 90, in runcode
exec(code, self.locals)
File "<input>", line 1, in <module>
File "/app/share/qgis/python/qgis/utils.py", line 793, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
ModuleNotFoundError: No module named 'scipy'
while the same works in my terminal.
Comments (3)
-
-
reporter Solved by uninstalling QGIS (I had installed it from flathub) and reinstalling following directions for Debian/Ubuntu in https://qgis.org/en/site/forusers/alldownloads.html#debian-ubuntu
Thanks
-
- changed status to resolved
- Log in to comment
It looks like qgis runs on another/its own python version. To find out where, check in the QGIS Python Console
Maybe also check the location of the python version you enter when you type python3 in the terminal. In your case they should be different.
Then try to explicitly use this path to run pip from the terminal, e.g.
Hope this works! In your case the path
/usr/bin/python3
will be different I guess. I am mostly testing inside a qgis docker container (based on Ubuntu 20.04) and there the “main” python instance is also the one qgis is using.