semiautomaticgit / SemiAutomaticClassificationPlugin

https://fromgistors.blogspot.com/p/semi-automatic-classification-plugin.html
Other
136 stars 50 forks source link

Semi-Automatic Classification Plugin: Error. Check Python Matplotlib installation for the Semi-Automatic Classification Plugin #195

Closed muhammadhanief closed 9 months ago

muhammadhanief commented 2 years ago

My problem is when i try to install pluign occured "Semi-Automatic Classification Plugin: Error. Check Python Matplotlib installation for the Semi-Automatic Classification Plugin". I'm using macos monterey M1 Chip. Thanks in advance

Jepretan Layar 2021-11-04 pukul 15 25 50 Jepretan Layar 2021-11-04 pukul 15 25 49
muhammadhanief commented 2 years ago
Jepretan Layar 2021-11-05 pukul 13 39 42

Here is the preview when i tested using matplotlib via command prompt

muhammadhanief commented 2 years ago

log file.txt

Jepretan Layar 2021-11-05 pukul 14 11 11

Date Function Message 2021-11-05 14.08.58.415411 SemiAutomaticClassificationPlugin.semiautomaticclassificationplugin-resetSCP 1471 LOG ACTIVE SemiAutomaticClass Version 7.10.5 - Matera - QGIS v. 31610 L:id - OS Darwin - 64bit =Yes - python path =/usr/bin/python3 2021-11-05 14.10.05.358421 SemiAutomaticClassificationPlugin.maininterface.settings-logCheckbox 144 LOG ACTIVE SemiAutomaticClass Version 7.10.5 - Matera - QGIS v. 31610 L:id - OS Darwin - 64bit =Yes - python path =/usr/bin/python3 2021-11-05 14.10.44.838905 SemiAutomaticClassificationPlugin.maininterface.settings-testNumpy 533 test: Success 2021-11-05 14.10.44.840695 SemiAutomaticClassificationPlugin.maininterface.settings-testScipy 544 test: Success 2021-11-05 14.10.44.841458 testMatplotlib 552 ERROR exception: dlopen(/Applications/QGIS-LTR.app/Contents/MacOS/lib/python3.8/site-packages/Pillow-7.2.0-py3.8-macosx-10.13.0-x86_64.egg/PIL/_imaging.cpython-38-darwin.so, 0x0002): Library not loaded: /opt/X11/lib/libxcb.1.dylib Referenced from: /Applications/QGIS-LTR.app/Contents/Resources/python/site-packages/pillow-7.2.0-py3.8-macosx-10.13.0-x86_64.egg/PIL/_imaging.cpython-38-darwin.so Reason: tried: '/opt/X11/lib/libxcb.1.dylib' (no such file), '/usr/local/lib/libxcb.1.dylib' (no such file), '/usr/lib/libxcb.1.dylib' (no such file) 2021-11-05 14.10.44.842236 SemiAutomaticClassificationPlugin.maininterface.settings-testMatplotlib 555 test: Fail 2021-11-05 14.10.44.843029 SemiAutomaticClassificationPlugin.maininterface.settings-testGDAL 295 gdal version:3.2 2021-11-05 14.10.44.844429 SemiAutomaticClassificationPlugin.maininterface.settings-testGDAL 310 test: Success 2021-11-05 14.10.44.845402 SemiAutomaticClassificationPlugin.core.utils-getGDALForMac 7616 getGDALForMac: /Library/Frameworks/GDAL.framework/Versions/3.2/Programs/ 2021-11-05 14.10.45.396964 SemiAutomaticClassificationPlugin.maininterface.settings-testGDALSubprocess 441 test: Success 2021-11-05 14.10.45.399201 SemiAutomaticClassificationPlugin.maininterface.settings-testSNAPSubprocess 449 SNAPGPT: 2021-11-05 14.10.45.399838 SemiAutomaticClassificationPlugin.maininterface.settings-testSNAPSubprocess 470 ERROR exception: module 'subprocess' has no attribute 'STARTUPINFO' 2021-11-05 14.10.45.419116 SemiAutomaticClassificationPlugin.maininterface.settings-testSNAPSubprocess 476 subprocess: 127 2021-11-05 14.10.45.421356 SemiAutomaticClassificationPlugin.maininterface.settings-testSNAPSubprocess 484 test: Fail 2021-11-05 14.10.45.422274 SemiAutomaticClassificationPlugin.maininterface.settings-testMultiprocess 357 python environ path: ['/Library/Frameworks/GDAL.framework/Programs', '/Library/Frameworks/Python.framework/Versions/3.8/bin', '/usr/bin', '/bin', '/usr/sbin', '/sbin'] 2021-11-05 14.10.45.423564 SemiAutomaticClassificationPlugin.maininterface.settings-testMultiprocess 417 test: Success 2021-11-05 14.10.45.690325 SemiAutomaticClassificationPlugin.maininterface.settings-testGDALMultiprocess 502 test: Success 2021-11-05 14.10.45.691489 SemiAutomaticClassificationPlugin.core.utils-downloadFile 351 url:https://semiautomaticgit.github.io/SemiAutomaticClassificationPluginWelcome/changelog.html 2021-11-05 14.10.45.692325 SemiAutomaticClassificationPlugin.core.utils-getProxyHandler 317
2021-11-05 14.10.46.248846 SemiAutomaticClassificationPlugin.maininterface.settings-testInternetConnection 514 test: Success 2021-11-05 14.12.01.190775 SemiAutomaticClassificationPlugin.maininterface.settings-logCheckbox 147 LOG DISABLED

semiautomaticgit commented 2 years ago

Hello @muhammadhanief ,

I think that matplotlib you installed is for a different version of Python that is not accessible by QGIS. You can try to follow this guide https://semiautomaticclassificationmanual.readthedocs.io/en/latest/faq.html#i-have-installation-issues-on-mac-os-how-can-i-install-scp-on-mac-os

muhammadhanief commented 2 years ago

Thanks for your answer. Based on the solution you provided, do I have to restart the installation from beginning? including reinstalling python? Do you think this failure is because I also installed anaconda on mac? because im also install anaconda

semiautomaticgit commented 2 years ago

You are welcome. Yes, you should restart the installation. I don't think Anaconda caused the issue, because it should be an independent installation.

mat1696 commented 2 years ago

Hello @muhammadhanief ,

I think that matplotlib you installed is for a different version of Python that is not accessible by QGIS. You can try to follow this guide https://semiautomaticclassificationmanual.readthedocs.io/en/latest/faq.html#i-have-installation-issues-on-mac-os-how-can-i-install-scp-on-mac-os

I've tried it on macOS Monterey but I get the following error (edit in fact I was able to install numpy using python3 -m pip install numpy… but then I ger dozens of other errors ): `Couldn't load plugin 'SemiAutomaticClassificationPlugin' due to an error when calling its classFactory() method

ModuleNotFoundError: No module named 'numpy' Traceback (most recent call last): File "/Applications/QGIS3.18.app/Contents/MacOS/../Resources/python/qgis/utils.py", line 335, in _startPlugin plugins[packageName] = package.classFactory(iface) File "/Users/mathis/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/SemiAutomaticClassificationPlugin/init.py", line 65, in classFactory from .semiautomaticclassificationplugin import SemiAutomaticClassificationPlugin File "/Applications/QGIS3.18.app/Contents/MacOS/../Resources/python/qgis/utils.py", line 799, in _import mod = _builtin_import(name, globals, locals, fromlist, level) File "/Users/mathis/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/SemiAutomaticClassificationPlugin/semiautomaticclassificationplugin.py", line 58, in import numpy as np File "/Applications/QGIS3.18.app/Contents/MacOS/../Resources/python/qgis/utils.py", line 799, in _import mod = _builtin_import(name, globals, locals, fromlist, level) ModuleNotFoundError: No module named 'numpy'

Python version: 3.9.5 (v3.9.5:0a7dcbdb13, May 3 2021, 13:17:02) [Clang 6.0 (clang-600.0.57)] QGIS version: 3.18.3-Zürich Zürich, exported

Python Path: /Applications/QGIS3.18.app/Contents/MacOS/../Resources/python /Users/mathis/Library/Application Support/QGIS/QGIS3/profiles/default/python /Users/mathis/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins /Applications/QGIS3.18.app/Contents/MacOS/../Resources/python/plugins /Library/Frameworks/SQLite3.framework/Versions/G/Python/3.9 /Library/Frameworks/Python.framework/Versions/3.9/lib/python39.zip /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9 /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/lib-dynload /Users/mathis/Library/Python/3.9/lib/python/site-packages /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages /Users/mathis/Library/Application Support/QGIS/QGIS3/profiles/default/python`

Please, help needed!

Capture d’écran 2022-04-07 à 00 38 15
semiautomaticgit commented 2 years ago

Hello, you can try to follow this installation guide https://semiautomaticclassificationmanual.readthedocs.io/en/latest/faq.html#i-have-installation-issues-on-mac-os-how-can-i-install-scp-on-mac-os

mat1696 commented 2 years ago

Hello, you can try to follow this installation guide https://semiautomaticclassificationmanual.readthedocs.io/en/latest/faq.html#i-have-installation-issues-on-mac-os-how-can-i-install-scp-on-mac-os

Thanks, yes I did. But I think the problem could be in uninstalling QGIS, Python3 and GDAL: For QGIS, I followed the Readme file (which uninstalled GDAL as well) and for Pyhton 3, this guide: https://www.macupdate.com/how-to/uninstall-python However there is maybe some old file remaining ? Even though my macOS install should be clean (at least before I first installed QGIS 3.22) as I did a clean install when macOS Monterey went out.

d2gex commented 2 years ago

Hi there,

This is how I solved it.

I am using macOS Catalina 10.15.3 and QGIS 3.22. When installing the latest version of SCP via Github I got the error prompted on the title of this issue. I had three version of python

QGIS 3.22 on its python 3.8 installation seem to have all requirements that SCP need: Matplotlib, Scipy, future and GDAL. However I believe that SCP was looking at my default underlying Python3 installation, the 3.7 version which obviously lacked all these packages, as I did not need them at all.

What I had to do is to get rid of QGIS 3.22 and my Python 3.7 version . Caution: if you have dependencies that requires 3.7, you'll break any software that needs Python 3.7. I then reinstalled QGIS, Python and GDAL separately via https://www.kyngchaos.com/software/qgis/ - not happy with this to be honest. See that the latest version available is QGIS 3.18.

Then I installed Maplotlib, Scipy and future using:

python3 -m pip install Matplotlib scipy future

Please see that python3 is a symbolic link to python3.9, that is to say, my just freshly installed Python interpreter because I deleted the older Python 3 versions.

Lastly I then reran the plugin installation and all worked smoothly.

Final thoughts: this is a chicken and egg situation. Whose fault is this? QGIS 3.22 installer seems to be relying on Python being shipped and installed locally. SCP seems to be looking for the default Python3 installation on the system. There seems to be a break in the communication here, hence the issues.

semiautomaticgit commented 2 years ago

Hello @d2gex , thank you for reporting this.

Final thoughts: this is a chicken and egg situation. Whose fault is this? QGIS 3.22 installer seems to be relying on Python being shipped and installed locally. SCP seems to be looking for the default Python3 installation on the system. There seems to be a break in the communication here, hence the issues.

The error Check Python Matplotlib installation for the Semi-Automatic Classification Plugin happens if the import of Matplotlib fails at the very beginning of plugin loading, and it relies on the Python environment provided by QGIS.

So I don't think that SCP is looking for the default Python 3 installation. However, I'll look into it.

d2gex commented 2 years ago

Thanks. Yeah, that is the weird thing. I supposed that SCP was looking at the environment pointed out by QGIS. When I browsed the site-packages within the QGIS's python environment I could see all the requirements that SCP needed. Albeit when I tried to install separately the dependencies, Python told me that such requirements were already satisfied - I did it via /Applications/QGIS.../python -m pip install x y x.

In addition when I ran "Test dependencies" within SCP, I got a few errors actually pointing out the the right QGIS environment. However a modal dialog came up that I could not get rid of unless I closed QGIS. Unfortunately I don't recall the exact message of that dialog.

I could though see matplotlib installed. The errors were pointing to matplotlib and gdal subprocesses but then in the logging details there was something else about PIL.

mat1696 commented 2 years ago

I can agree with @d2gex my investigations lead to the same result.

semiautomaticgit commented 2 years ago

Thank you @d2gex and @mat1696 for your feedback.

In addition when I ran "Test dependencies" within SCP, I got a few errors actually pointing out the the right QGIS environment. However a modal dialog came up that I could not get rid of unless I closed QGIS. Unfortunately I don't recall the exact message of that dialog. The issues running "Test dependencies" could be also related to the multiprocessing environment. However, the installation error related to Matplotlib dependency have a different cause.

The strange thing is that these issues are not replicable on Linux OS or Windows OS, so it must be something specific of Mac OS.

yukihuang0422 commented 1 year ago

Hi, I met the same problem. My OS is MacOS 11.6.7 Big Sur. I used to use QGIS 3.18, SCP works well on that. I just download QGIS 3.22 LTR today, and SCP shows Error. Check Python Matplotlib installation for the Semi-Automatic Classification Plugin. My python version is 3.8 and I'm pretty sure I have download matplotlib. Also, I have tried method from [https://gis.stackexchange.com/questions/366848/scp-plugin-for-qgis-3-10-on-mac] but it doesn't work. Could you help me with it?

semiautomaticgit commented 1 year ago

Hi, I met the same problem. My OS is MacOS 11.6.7 Big Sur. I used to use QGIS 3.18, SCP works well on that. I just download QGIS 3.22 LTR today, and SCP shows Error. Check Python Matplotlib installation for the Semi-Automatic Classification Plugin. My python version is 3.8 and I'm pretty sure I have download matplotlib. Also, I have tried method from [https://gis.stackexchange.com/questions/366848/scp-plugin-for-qgis-3-10-on-mac] but it doesn't work. Could you help me with it?

Hello, unfortunately it seems that recent versions of QGIS has issues with the installation of SCP. You should try the previous version of QGIS

semiautomaticgit commented 9 months ago

I'm closing this because of the new version 8 of SCP. Please reopen it if it is still relevant in the new version. Thank you!