Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Gaurab0664 opened this issue Feb 3, 2024 · 1 comment

Comments

@Gaurab0664
Copy link

ImportError: cannot import name 'gcd' from 'fractions' (C:\PROGRA1\QGIS321.13\apps\Python39\lib\fractions.py)
Traceback (most recent call last):
File "C:\PROGRA1/QGIS321.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:\PROGRA1/QGIS321.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:\PROGRA1/QGIS321.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:\PROGRA1/QGIS321.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:\PROGRA1/QGIS321.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:\PROGRA1/QGIS321.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:\PROGRA1/QGIS321.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:\PROGRA1\QGIS321.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
Copy link

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants