Geo-SAM fails to load QGIS 3.36.2
Opened this issue · 6 comments
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:\PROGRA1/QGIS332.2/apps/qgis/./python\qgis\utils.py", line 404, in loadPlugin
import(packageName)
File "C:\PROGRA1/QGIS332.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:\PROGRA1/QGIS332.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:\PROGRA1/QGIS332.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:\PROGRA1/QGIS332.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:/PROGRA1/QGIS332.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:/PROGRA1/QGIS332.2/apps/qgis/./python/plugins
C:\PROGRA1\QGIS332.2\apps\grass\grass83\etc\python
C:\Users\marti\Documents
C:\Program Files\QGIS 3.36.2\bin\python312.zip
C:\PROGRA1\QGIS332.2\apps\Python312\DLLs
C:\PROGRA1\QGIS332.2\apps\Python312\Lib
C:\Program Files\QGIS 3.36.2\bin
C:\PROGRA1\QGIS332.2\apps\Python312
C:\PROGRA1\QGIS332.2\apps\Python312\Lib\site-packages
C:\PROGRA1\QGIS332.2\apps\Python312\Lib\site-packages\win32
C:\PROGRA1\QGIS332.2\apps\Python312\Lib\site-packages\win32\lib
C:\PROGRA1\QGIS332.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
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.
I've:
- Uninstalled and reinstalled QGIS 3.36.2
- Followed the installation instructions doing a force re-install.
- Now getting the following error (again seems to be path error:
2024-05-05T12:06:17 CRITICAL Traceback (most recent call last):
File "C:\PROGRA1/QGIS332.2/apps/qgis/./python\qgis\utils.py", line 404, in loadPlugin
import(packageName)
File "C:\PROGRA1/QGIS332.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:\PROGRA1/QGIS332.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:\PROGRA1/QGIS332.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 21, in
from torchgeo.datasets import BoundingBox
File "C:\PROGRA1/QGIS332.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\Python\Python312\site-packages\torchgeo\datasets_init.py", line 6, in
from .advance import ADVANCE
File "C:\PROGRA1/QGIS332.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\Python\Python312\site-packages\torchgeo\datasets\advance.py", line 12, in
import torch
File "C:\PROGRA1/QGIS332.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\Python\Python312\site-packages\torch_init.py", line 141, in
raise err
OSError: [WinError 126] The specified module could not be found. Error loading "C:\Users\marti\AppData\Roaming\Python\Python312\site-packages\torch\lib\shm.dll" or one of its dependencies.
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:/PROGRA1/QGIS332.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:/PROGRA1/QGIS332.2/apps/qgis/./python/plugins
C:\PROGRA1\QGIS332.2\apps\grass\grass83\etc\python
C:\Users\marti\Documents
C:\Program Files\QGIS 3.36.2\bin\python312.zip
C:\PROGRA1\QGIS332.2\apps\Python312\DLLs
C:\PROGRA1\QGIS332.2\apps\Python312\Lib
C:\Program Files\QGIS 3.36.2\bin
C:\Users\marti\AppData\Roaming\Python\Python312\site-packages
C:\PROGRA1\QGIS332.2\apps\Python312
C:\PROGRA1\QGIS332.2\apps\Python312\Lib\site-packages
C:\PROGRA1\QGIS332.2\apps\Python312\Lib\site-packages\win32
C:\PROGRA1\QGIS332.2\apps\Python312\Lib\site-packages\win32\lib
C:\PROGRA1\QGIS332.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!
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/
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.
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.