Huite / gflow-plugin

QGIS plugin for the GFLOW analytic element program
GNU General Public License v3.0
0 stars 1 forks source link

QGIS python version requirements #2

Open aleaf opened 1 week ago

aleaf commented 1 week ago

Hi @Huite, I cloned the plugin down to my machine, created the symlink andwas able to get the GFLOW icon to appear in QGIS. However, when I click on the icon to start the plugin, I get this error message:

An error has occurred while executing Python code: 

SyntaxError: invalid syntax 
Traceback (most recent call last):
  File "/Users/aleaf/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/gflow/gflow.py", line 36, in toggle_gflow
    from .widgets.gflow_widget import GflowWidget
  File "/Applications/QGIS.app/Contents/MacOS/lib/python3.9/qgis/utils.py", line 923, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "/Users/aleaf/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/gflow/widgets/gflow_widget.py", line 29, in 
    from gflow.widgets.dataset_widget import DatasetWidget
  File "/Applications/QGIS.app/Contents/MacOS/lib/python3.9/qgis/utils.py", line 923, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "/Users/aleaf/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/gflow/widgets/dataset_widget.py", line 33, in 
    from gflow.core.elements import Aquifer, Domain, load_elements_from_geopackage
  File "/Applications/QGIS.app/Contents/MacOS/lib/python3.9/qgis/utils.py", line 923, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "/Users/aleaf/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/gflow/core/elements/__init__.py", line 7, in 
    from gflow.core.elements.aquifer import Aquifer
  File "/Applications/QGIS.app/Contents/MacOS/lib/python3.9/qgis/utils.py", line 923, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "/Users/aleaf/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/gflow/core/elements/aquifer.py", line 7, in 
    from gflow.core.elements.element import Element
  File "/Applications/QGIS.app/Contents/MacOS/lib/python3.9/qgis/utils.py", line 923, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "/Users/aleaf/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/gflow/core/elements/element.py", line 227
    match self.geometry_type:
          ^
SyntaxError: invalid syntax

Python version: 3.9.5 (default, Sep 10 2021, 16:18:19) [Clang 12.0.5 (clang-1205.0.22.11)] 
QGIS version: 3.38.3-Grenoble Grenoble, 37f9e6efeec 

It seems that this is an issue with match statements being introduced in Python 3.10 and me having Python 3.9 (which I'm assuming was bundled with QGIS; this is the path to the python distribution: /Applications/QGIS.app/Contents/MacOS/lib/python3.9/site-packages.

I suspect this might be an issue for many others. I installed QGIS on my Mac via the installer for the latest version from the QGIS Downloads page. Do you know if there's an easy way to upgrade the python distribution that is bundled with QGIS, on any platform? Or perhaps a better solution for now would be to support/test against 3.9 until a newer version of Python is bundled?

Huite commented 1 week ago

Hey @aleaf

I think in this case we should just replace the match statements by if else. They're nice, but hardly essential -- feel free to make a PR!