3

I had been struggling to get QGIS installed because (currently) the ubuntugis repo seems to not be working well (couldn’t load Python at all). I got around that problem by installing QGIS using flatpak.

I neeed to use the ENMAPBox plugin, which requires SciPy, Numpy, and Sklearn modules. Ubuntu came with Python 3.6.8 installed and QGIS brought with it Python 3.7.3. ENMAPBox cannot start because it can’t find either of those modules, and importing them from the console yields the same response. I followed the plugin’s instructions to install those packages using python3 -m pip install.

I’ve verified that the executable used by QGIS python console is /usr/bin/python3, and inspecting sys.path shows that /usr/lib/python3/dis-packages is not in the path (so it would make sense that it can’t find the packages I installed using pip3).

Sys.path looks like this:

['/app/share/qgis/python', '/home/nav00a/.var/app/org.qgis.qgis/data/QGIS/QGIS3/profiles/default/python', '/home/nav00a/.var/app/org.qgis.qgis/data/QGIS/QGIS3/profiles/default/python/plugins', '/app/share/qgis/python/plugins', '/usr/lib/python37.zip', '/usr/lib/python3.7', '/usr/lib/python3.7/lib-dynload', '/usr/lib/python3.7/site-packages', '/app/lib/python3.7/site-packages', '/app/lib/python3.7/site-packages/numpy-1.14.3-py3.7-linux-x86_64.egg', '/app/lib/python3.7/site-packages/MarkupSafe-1.0-py3.7-linux-x86_64.egg', '/home/nav00a/.var/app/org.qgis.qgis/data/QGIS/QGIS3/profiles/default/python', '/home/nav00a/.var/app/org.qgis.qgis/data/QGIS/QGIS3/profiles/default/python/plugins/enmapboxplugin/site-packages', '/home/nav00a/.var/app/org.qgis.qgis/data/QGIS/QGIS3/profiles/default/python/plugins/enmapboxplugin/enmapbox', '/usr/lib/python3/dist-packages']�

Note the last item is there because I appended it, it’s not there by default.

To get QGIS to import SciPy I’ve tried a number of things:

  • Appending /usr/lib/python3/dist-packages to sys.path
  • Redirecting pip3 to /usr/lib/python3.7/site-packages
  • Adding .pth files to /usr/lib/python3.7/site-packages and /home/nav00a/.var/app/org.qgis.qgis/data/QGIS/QGIS3/profiles/default/python/plugins/enmapboxplugin/site-packages with links to /usr/lib/python3/dust-packages and /usr/lib/python3.7/site-packages

Unfortunately the behaviour remains the same. If I import SciPy this is what I get:

Traceback (most recent call last):
  File "/usr/lib/python3.7/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 672, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
ModuleNotFoundError: No module named 'scipy'�

Am I missing something that’s very obvious?

  • If you have those issues with Ubuntu, you can use Debian 10 buster (new stable version). It is easily installed with whatever DVD live version in only 15-20 minutes. Afterward, install QGIS 3.8 with its stable repository. By the way, a few minutes ago, I spent only two minutes installing EnMap-Box 3 after installing scipy and scikit-learn with pip3. It's only a suggestion. – xunilk Aug 29 at 5:04
  • Thanks for the suggestion xunilk. Distro choice is not straightforward as this is an enterprise VM and it depends on what my IT department prefers. But I’ll contact them and suggest changing to Debian. – Javi_Navarro Sep 1 at 23:19
  • You're welcome. You can try in your PC first. In my link, imgur.com/oCEfQj4, you can see an image of installed plugin in only two minutes after installing scipy and scikit-learn with pip3. – xunilk Sep 2 at 3:26
0

I just found out apparently the flatpak version of QGIS does not allow for new Python modules to be installed at all. It seems circumventing the broken QGIS repository with flatpak was a dead end after all.

On top of that, in case others are having the same broken dependencies issue with the ubuntugis repo (and in my case the ltr release repo) the nightly release works much better.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.