UMEP-dev / UMEP

Urban Multi-scale Environmental Predictor
https://umep-docs.readthedocs.io/
59 stars 15 forks source link

Error when installing UMEP for Processing on Mac OS #543

Closed jlegewie closed 10 months ago

jlegewie commented 10 months ago

Describe the bug I am unable to install UMEP for Processing with the most recent QGIS version (3.32.2) because of various issues with the numpy version. This is related to previous questions (such as this one) but nothing solved the problem. I will go through each attempted solution here.

  1. I am using a fresh install of QGIS (including deleting "~/Library/Application Support/QGIS" before install)
  2. Installing UMEP for processing fails with this error message. The error message appears after the prompt "Do you automatically want to..."
ImportError: this version of pandas is incompatible with numpy your numpy version is 1.20.1.
Please upgrade numpy to >= 1.20.3 to use this pandas version"
  1. I follow the instructions to upgrade numpy here, which installs numpy version 1.25.2. However, when restarting QGIS, I get an error that jaydebeapi is not installed. So I install that using the same approach
/Applications/QGIS.app/Contents/MacOS/bin/python3 -m pip install --upgrade numpy
/Applications/QGIS.app/Contents/MacOS/bin/python3 -m pip install --upgrade jaydebeapi
  1. On restart, I now get the error module 'numpy' has no attribute 'long'. Turns out numpy.long was deprecated in numpy 1.20 and it is removed in numpy 1.24. (link). I did not find a discussion of this issue. To solve it, I specify the numpy version 1.20.3 like this, which is the minimum version from the first error.
/Applications/QGIS.app/Contents/MacOS/bin/python3 -m pip install --upgrade numpy==1.20.3
  1. On restart, I get the error module compiled against API version 0xf but this version of numpy is 0xe. I found two discussion on this issue a. The answer here suggests that installing the most recent version of QGIS might help. I am using the most recent version and it is a fresh install. b. The answer here suggests that I upgrade numpy. I already went through this process (see 3-4 above)

Any solution to these issues?

Desktop (please complete the following information):

Full error at the end including

An error has occurred while executing Python code: 

RuntimeError: module compiled against API version 0xf but this version of numpy is 0xe 
RuntimeError: module compiled against API version 0xf but this version of numpy is 0xe

Python version: 3.9.5 (default, Sep 10 2021, 16:18:19) [Clang 12.0.5 (clang-1205.0.22.11)] 
QGIS version: 3.32.2-Lima Lima, c0b88339649 

Python Path:
/Applications/QGIS.app/Contents/MacOS/../Resources/python
/Users/jlegewie/Library/Application Support/QGIS/QGIS3/profiles/default/python
/Users/jlegewie/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins
/Applications/QGIS.app/Contents/MacOS/../Resources/python/plugins
/Applications/QGIS.app/Contents/MacOS/lib/python3.9/site-packages/statsmodels-0.11.1-py3.9-macosx-10.13.0-x86_64.egg
/Applications/QGIS.app/Contents/MacOS/lib/python3.9/site-packages/opencv_contrib_python-4.3.0.36-py3.9-macosx-10.13.0-x86_64.egg
/Applications/QGIS.app/Contents/MacOS/lib/python3.9/site-packages/Pillow-7.2.0-py3.9-macosx-10.13.0-x86_64.egg
/Applications/QGIS.app/Contents/MacOS/lib/python3.9/site-packages/netCDF4-1.5.4-py3.9-macosx-10.13.0-x86_64.egg
/Applications/QGIS.app/Contents/MacOS/lib/python3.9/site-packages/scipy-1.5.1-py3.9-macosx-10.13.0-x86_64.egg
/Applications/QGIS.app/Contents/MacOS/lib/python3.9/site-packages/cftime-1.2.1-py3.9-macosx-10.13.0-x86_64.egg
/Applications/QGIS.app/Contents/MacOS/lib/python3.9/site-packages/matplotlib-3.3.0-py3.9-macosx-10.13.0-x86_64.egg
/Applications/QGIS.app/Contents/MacOS/lib/python3.9/site-packages/rasterio-1.1.5-py3.9-macosx-10.13.0-x86_64.egg
/Applications/QGIS.app/Contents/MacOS/lib/python3.9/site-packages/geopandas-0.8.1-py3.9.egg
/Users/jlegewie/.local/lib/python3.9/site-packages
/Applications/QGIS.app/Contents/MacOS/lib/python39.zip
/Applications/QGIS.app/Contents/MacOS/lib/python3.9/site-packages/patsy-0.5.1-py3.9.egg
/Applications/QGIS.app/Contents/MacOS/lib/python3.9/site-packages/pyproj-3.2.0-py3.9-macosx-10.13.0-x86_64.egg
/Applications/QGIS.app/Contents/MacOS/lib/python3.9/lib-dynload
/Applications/QGIS.app/Contents/MacOS/lib/python3.9/site-packages/Fiona-1.8.13.post1-py3.9-macosx-10.13.0-x86_64.egg
/Applications/QGIS.app/Contents/MacOS/lib/python3.9/site-packages
/Applications/QGIS.app/Contents/MacOS/lib/python3.9/site-packages/pandas-1.3.3-py3.9-macosx-10.13.0-x86_64.egg
/Applications/QGIS.app/Contents/MacOS/lib/python3.9
/Applications/QGIS.app/Contents/MacOS/lib/python3.9/site-packages/GDAL-3.3.2-py3.9-macosx-10.13.0-x86_64.egg
/Applications/QGIS.app/Contents/MacOS/lib/python3.9/site-packages/Rtree-0.9.7-py3.9-macosx-10.13.0-x86_64.egg
/Applications/QGIS.app/Contents/MacOS/lib/python3.9/site-packages/numba-0.50.1-py3.9-macosx-10.13.0-x86_64.egg
/Users/jlegewie/Library/Application Support/QGIS/QGIS3/profiles/default/python
j3r3m1 commented 10 months ago

Hi @jlegewie thank you for this complete attempt. Have you tried an other version of Numpy such as 1.23.3 such as used in https://github.com/UMEP-dev/UMEP-processing/issues/30 ?

jlegewie commented 10 months ago

YES. numpy 1.23.3 worked. Thanks! This was a journey.

I am closing the issue and including step-by-step instructions below for anyone who has similar problems.

  1. Determine the python interpreter used by your QGIS. The instructions to do that are here. On my mac, the location is: /Applications/QGIS.app/Contents/MacOS/bin/python3
  2. Install correct version of numpy outside of QGIS. Just open the Terminal on your mac and type the code below (of course, change the path to the correct version of python from step 1).

/Applications/QGIS.app/Contents/MacOS/bin/python3 -m pip install --upgrade numpy==1.23.3
  1. Restart QGIS. Install UMEP and UMEP for Processing.
j3r3m1 commented 10 months ago

Thanks for sharing your instructions !