coolzhao / Geo-SAM

A QGIS plugin tool using Segment Anything Model (SAM) to accelerate segmenting or delineating landforms in geospatial raster images.
MIT License
240 stars 37 forks source link

Geo-SAM fails to load QGIS 3.36.2 #44

Open Martin-Dawson opened 6 months ago

Martin-Dawson commented 6 months ago

I am getting the following error when trying to initial Geo-SAM in QGIS v3.36.2:

ModuleNotFoundError: No module named 'rasterio' Traceback (most recent call last): File "C:\PROGRA~1/QGIS33~2.2/apps/qgis/./python\qgis\utils.py", line 404, in loadPlugin import(packageName) File "C:\PROGRA~1/QGIS33~2.2/apps/qgis/./python\qgis\utils.py", line 923, in _import mod = _builtin_import(name, globals, locals, fromlist, level) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users/marti/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\Geo-SAM__init__.py", line 7, in from .geo_sam_tool import Geo_SAM File "C:\PROGRA~1/QGIS33~2.2/apps/qgis/./python\qgis\utils.py", line 923, in _import mod = _builtin_import(name, globals, locals, fromlist, level) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users/marti/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\Geo-SAM\geo_sam_tool.py", line 10, in from .tools.widgetTool import Selector, EncoderCopilot File "C:\PROGRA~1/QGIS33~2.2/apps/qgis/./python\qgis\utils.py", line 923, in _import mod = _builtin_import(name, globals, locals, fromlist, level) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users/marti/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\Geo-SAM\tools\widgetTool.py", line 7, in import rasterio File "C:\PROGRA~1/QGIS33~2.2/apps/qgis/./python\qgis\utils.py", line 923, in _import mod = _builtin_import(name, globals, locals, fromlist, level) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ModuleNotFoundError: No module named 'rasterio'

Python version: 3.12.3 (main, Apr 14 2024, 17:21:43) [MSC v.1938 64 bit (AMD64)] QGIS version: 3.36.2-Maidenhead Maidenhead, 6d250527

Python Path: C:\Users/marti/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\geometric_attributes C:/PROGRA~1/QGIS33~2.2/apps/qgis/./python C:/Users/marti/AppData/Roaming/QGIS/QGIS3\profiles\default/python C:/Users/marti/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins C:/PROGRA~1/QGIS33~2.2/apps/qgis/./python/plugins C:\PROGRA~1\QGIS33~2.2\apps\grass\grass83\etc\python C:\Users\marti\Documents C:\Program Files\QGIS 3.36.2\bin\python312.zip C:\PROGRA~1\QGIS33~2.2\apps\Python312\DLLs C:\PROGRA~1\QGIS33~2.2\apps\Python312\Lib C:\Program Files\QGIS 3.36.2\bin C:\PROGRA~1\QGIS33~2.2\apps\Python312 C:\PROGRA~1\QGIS33~2.2\apps\Python312\Lib\site-packages C:\PROGRA~1\QGIS33~2.2\apps\Python312\Lib\site-packages\win32 C:\PROGRA~1\QGIS33~2.2\apps\Python312\Lib\site-packages\win32\lib C:\PROGRA~1\QGIS33~2.2\apps\Python312\Lib\site-packages\Pythonwin C:/Users/marti/AppData/Roaming/QGIS/QGIS3\profiles\default/python C:\Users\marti\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\deepness\python3.12 C:\Users\marti\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\DigitizingTools\tools C:\Users\marti\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\DigitizingTools C:\Users\marti\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\HCMGIS/forms C:\Users/marti/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\rvt-qgis

The problem does not occur in QGIS v3.36.1

There seem to have been a substantial number of Python version updates in 3.36.2: https://lists.osgeo.org/pipermail/qgis-user/2024-April/054334.html

Fanchengyan commented 6 months ago

Hi @Martin-Dawson

This is likely due to the path of the Python dependencies is incorrect. Please follow the tutorial and reinstall the python dependencies: https://geo-sam.readthedocs.io/en/latest/installation.html#for-windows-users. Since you have installed two versions of QGIS, there should be two OSGeo4W Shells. Make sure to select the one corresponding to the QGIS v3.36.2.

Martin-Dawson commented 6 months ago

I've:

Python Path: C:\Users/marti/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\geometric_attributes C:/PROGRA~1/QGIS33~2.2/apps/qgis/./python C:/Users/marti/AppData/Roaming/QGIS/QGIS3\profiles\default/python C:/Users/marti/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins C:/PROGRA~1/QGIS33~2.2/apps/qgis/./python/plugins C:\PROGRA~1\QGIS33~2.2\apps\grass\grass83\etc\python C:\Users\marti\Documents C:\Program Files\QGIS 3.36.2\bin\python312.zip C:\PROGRA~1\QGIS33~2.2\apps\Python312\DLLs C:\PROGRA~1\QGIS33~2.2\apps\Python312\Lib C:\Program Files\QGIS 3.36.2\bin C:\Users\marti\AppData\Roaming\Python\Python312\site-packages C:\PROGRA~1\QGIS33~2.2\apps\Python312 C:\PROGRA~1\QGIS33~2.2\apps\Python312\Lib\site-packages C:\PROGRA~1\QGIS33~2.2\apps\Python312\Lib\site-packages\win32 C:\PROGRA~1\QGIS33~2.2\apps\Python312\Lib\site-packages\win32\lib C:\PROGRA~1\QGIS33~2.2\apps\Python312\Lib\site-packages\Pythonwin C:/Users/marti/AppData/Roaming/QGIS/QGIS3\profiles\default/python C:\Users\marti\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\deepness\python3.12 C:\Users\marti\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\DigitizingTools\tools C:\Users\marti\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\DigitizingTools C:\Users\marti\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\HCMGIS/forms C:\Users/marti/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\rvt-qgis

Suggestions please!

Fanchengyan commented 6 months ago

Hi @Martin-Dawson ,

This seems to be a problem with the PyTorch installation. Make sure you have installed the PyTorch version that corresponds to your CUDA version, or directly install the CPU version of PyTorch. The following links are for reference : https://stackoverflow.com/questions/61488902/cannot-import-pytorch-winerror-126-the-specified-module-could-not-be-found https://pytorch.org/get-started/locally/

Martin-Dawson commented 6 months ago

QGIS v3.36.2 has a load of updates: https://lists.osgeo.org/pipermail/qgis-user/2024-April/054334.html. I suspect this is the source of the issue I've raised rather than Pytorch-CUDA incompatibility. Note this update should solve the RTree issue.

Fanchengyan commented 6 months ago

Hi @Martin-Dawson ,

I tested it in Windows, and the code prompted a permission issue.

Try to launch the OSGeo4W Shell as administrator and run the following command.

pip3 install torch --force-reinstall

This worked for me.

Martin-Dawson commented 6 months ago

Many thanks. Forcing the reinstall running the Shell as an administrator resolved the problem. The earlier installs I did (not as Administrator) seem to have produced several invalid torch distributions (now removed to avoid warnings!)


From: Fanchengyan @.> Sent: 07 May 2024 09:52 To: coolzhao/Geo-SAM @.> Cc: Martin-Dawson @.>; Mention @.> Subject: Re: [coolzhao/Geo-SAM] Geo-SAM fails to load QGIS 3.36.2 (Issue #44)

Hi @Martin-Dawsonhttps://github.com/Martin-Dawson ,

I tested it in Windows, and the code prompted a permission issue.

Try to launch the OSGeo4W Shell as administrator and run the following command.

pip3 install torch --force-reinstall

This worked for me.

— Reply to this email directly, view it on GitHubhttps://github.com/coolzhao/Geo-SAM/issues/44#issuecomment-2097783094, or unsubscribehttps://github.com/notifications/unsubscribe-auth/BC3PZPEDD23YFRR4SMXIA23ZBCI3JAVCNFSM6AAAAABHHCYW4CVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOJXG44DGMBZGQ. You are receiving this because you were mentioned.Message ID: @.***>