unable to install required Python packages for enmap-box on Mac running Mojave

Issue #453 on hold
William Farrand created an issue

I have a MacBook Pro running Mojave and QGIS 3.12 installed. When trying to invoke the Enmap-Box plug-in, I get a message saying I’m missing required Python packages. Then when trying to run the package installer, I get the following set of messages:

Search for installed versions...

/usr/bin/python -m pip install --user --upgrade pip>=20.0

/bin/sh: =20.0: Permission denied

/usr/bin/python -m pip install --user --upgrade scikit-learn>=0.19.2

/bin/sh: =0.19.2: Permission denied

/usr/bin/python -m pip install --user --upgrade astropy

ImportError: No module named site

/usr/bin/python -m pip install --user --upgrade PyOpenGL

ImportError: No module named site

/usr/bin/python -m pip install --user --upgrade numba<=0.47 ; platform_system != "Linux"

Blocked pip install numba

Reason: should to be installed manually using the local package manager.

please read <a href="https://numba.pydata.org/numba-doc/dev/user/installing.html">https://numba.pydata.org/numba-doc/dev/user/installing.html</a> for details

Please install manually with your local package manager

/usr/bin/python -m pip install --user --upgrade netCDF4

ImportError: No module named site

/usr/bin/python -m pip install --user --upgrade enpt-enmapboxapp

ImportError: No module named site

Search for installed versions...

I have other Python installations on my machine and so I’m not sure how to isolate the version of Python that QGIS/Enmap-Box wants to access to “manually” install the packages via pip.

Comments (10)

  1. Benjamin Jakimow

    Thanks for your question @William Farrand , obviously the QGIS python does not have writing access to the --user directory (curious engough), but I try to find a solution for this problem.

    In general you are right: we need to isolate the python that is used by QGIS. AFAIK on macOS this is below the QGIS.app/Content/… Python.Framework/ folder.

    How did you install QGIS? Have you used

    1. the signed installer from https://www.qgis.org/en/site/forusers/download.html,
    2. the QGIS from https://www.kyngchaos.com/frameworks/
    3. a QGIS installed with homebrew, or
    4. did you choose a anaconda/miniconda installation?
  2. William Farrand reporter

    @Benjamin Jakimow any more thoughts on this? Changing the PATH variable in QGIS to get it to look for another Python installation and in that installation the required packages are installed, but after invoking Enmap-Box I still get the message saying that those packages aren’t installed.

  3. Benjamin Jakimow

    @William Farrand unfortunatelly you cannot change the python that is used by QGIS. In principle, the installation of python packages into the QGIS python should work after starting the terminal.app with a bash / zsh shell that uses the same environmental variables as the QGIS.app as well. AFAIK this requires to set the terminal with same PATH and PYTHONPATH values, e.g. in a terminal.app

    Unfortunatelly I don’t have a working macBook anymore and cannot test it for you. Probably there are some more caveats in the recent macOS version (and stackoverflow responses like https://gis.stackexchange.com/questions/123251/calling-qgis-from-macos-python seem to be outdated)

    However, as installing python packages to a signed QGIS.app is complicated, a workaround might be to install QGIS within a conda / anaconda environment. This allows you to manage python packages as you like, and we will describe this in the EnMAP-Box documentation soon. So far you might read section “3. Create a conda environment with QGIS” from https://scm.cms.hu-berlin.de/jakimowb/geoprocessing_course to install a conda QGIS on your macOS. Then you can install required python package like:

    (qgis_stable) $>conda install scikit-learn --channel=conda-forge
    (qgis_stable) $>conda install scipy --channel=conda-forge
    (qgis_stable) $>conda install matplotlib --channel=conda-forge
    

    and start the conda QGIS like:

    (qgis_stable) $qgis
    

  4. William Farrand reporter

    Installing QGIS from the conda environment as you suggested, and then manually installing the individual packages, did the trick. I have Enmap-box running now. Thanks very much for the help!

  5. Log in to comment