its4land / qgis-boundary-delineation

QGIS3 plugin for image-based boundary delineation
https://its4land.com/automate-it-wp5/
MIT License
9 stars 4 forks source link

Couldn't load plugin 'BoundaryDelineation' due to an error when calling its classFactory() method #13

Open Gaurab0664 opened 5 months ago

Gaurab0664 commented 5 months ago

ImportError: cannot import name 'gcd' from 'fractions' (C:\PROGRA~1\QGIS32~1.13\apps\Python39\lib\fractions.py) Traceback (most recent call last): File "C:\PROGRA~1/QGIS32~1.13/apps/qgis-ltr/./python\qgis\utils.py", line 423, in _startPlugin plugins[packageName] = package.classFactory(iface) File "C:\Users/Dell/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\BoundaryDelineation__init.py", line 37, in classFactory from .BoundaryDelineation import BoundaryDelineation File "C:\PROGRA~1/QGIS32~1.13/apps/qgis-ltr/./python\qgis\utils.py", line 888, in _import mod = _builtin_import(name, globals, locals, fromlist, level) File "C:\Users/Dell/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\BoundaryDelineation\BoundaryDelineation.py", line 48, in import networkx as nx File "C:\PROGRA~1/QGIS32~1.13/apps/qgis-ltr/./python\qgis\utils.py", line 888, in _import mod = _builtin_import(name, globals, locals, fromlist, level) File "C:\Users/Dell/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\BoundaryDelineation/lib\networkx__init__.py", line 114, in import networkx.generators File "C:\PROGRA~1/QGIS32~1.13/apps/qgis-ltr/./python\qgis\utils.py", line 888, in _import mod = _builtin_import(name, globals, locals, fromlist, level) File "C:\Users/Dell/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\BoundaryDelineation/lib\networkx\generators\init.py", line 14, in from networkx.generators.intersection import * File "C:\PROGRA~1/QGIS32~1.13/apps/qgis-ltr/./python\qgis\utils.py", line 888, in _import mod = _builtin_import(name, globals, locals, fromlist, level) File "C:\Users/Dell/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\BoundaryDelineation/lib\networkx\generators\intersection.py", line 13, in from networkx.algorithms import bipartite File "C:\PROGRA~1/QGIS32~1.13/apps/qgis-ltr/./python\qgis\utils.py", line 888, in _import mod = _builtin_import(name, globals, locals, fromlist, level) File "C:\Users/Dell/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\BoundaryDelineation/lib\networkx\algorithms\init__.py", line 16, in from networkx.algorithms.dag import * File "C:\PROGRA~1/QGIS32~1.13/apps/qgis-ltr/./python\qgis\utils.py", line 888, in _import mod = _builtin_import(name, globals, locals, fromlist, level) File "C:\Users/Dell/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\BoundaryDelineation/lib\networkx\algorithms\dag.py", line 23, in from fractions import gcd ImportError: cannot import name 'gcd' from 'fractions' (C:\PROGRA~1\QGIS32~1.13\apps\Python39\lib\fractions.py)

Python version: 3.9.5 (tags/v3.9.5:0a7dcbd, May 3 2021, 17:27:52) [MSC v.1928 64 bit (AMD64)] QGIS version: 3.28.13-Firenze Firenze, 3b4db4f561

ap-Codkelden commented 4 months ago

@Gaurab0664 As of Python version 3.9, fractions.gcd(a, b) has been moved to the math module. As a temporary fix, you should change the line from fractions import gcd (at the beginning of this file) to from math import gcd

For me, changing the file ./BoundaryDelineation/lib/networkx/readwrite is also needed due to deprecation of the np.int. You should find this line and change (np.int, "int") to (int, "int").

It works with Python 3.11.6 and QGIS 3.34.3-Prizren. I hope it helps.