rkistner / chinese-postman

Python application to solve the Chinese postman problem
MIT License
55 stars 15 forks source link

Cannot import gcd from fractions #26

Open mapperfr opened 1 year ago

mapperfr commented 1 year ago

Hi,

I'm running into an import error. Here's the log:

ImportError: cannot import name 'gcd' from 'fractions' (/usr/lib/python3.10/fractions.py) 
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/qgis/utils.py", line 423, in _startPlugin
    plugins[packageName] = package.classFactory(iface)
  File "/home/jeremy/.local/share/QGIS/QGIS3/profiles/default/python/plugins/chinesepostman/__init__.py", line 34, in classFactory
    from .chinesepostman import ChinesePostman
  File "/usr/lib/python3/dist-packages/qgis/utils.py", line 888, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "/home/jeremy/.local/share/QGIS/QGIS3/profiles/default/python/plugins/chinesepostman/chinesepostman.py", line 27, in 
    from . import postman
  File "/usr/lib/python3/dist-packages/qgis/utils.py", line 888, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "/home/jeremy/.local/share/QGIS/QGIS3/profiles/default/python/plugins/chinesepostman/postman.py", line 18, in 
    import networkx as nx
  File "/usr/lib/python3/dist-packages/qgis/utils.py", line 888, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "/home/jeremy/.local/share/QGIS/QGIS3/profiles/default/python/plugins/chinesepostman/lib/networkx-1.7-py2.7.egg/networkx/__init__.py", line 76, in 
    import networkx.algorithms
  File "/usr/lib/python3/dist-packages/qgis/utils.py", line 888, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "/home/jeremy/.local/share/QGIS/QGIS3/profiles/default/python/plugins/chinesepostman/lib/networkx-1.7-py2.7.egg/networkx/algorithms/__init__.py", line 11, in 
    from networkx.algorithms.dag import *
  File "/usr/lib/python3/dist-packages/qgis/utils.py", line 888, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "/home/jeremy/.local/share/QGIS/QGIS3/profiles/default/python/plugins/chinesepostman/lib/networkx-1.7-py2.7.egg/networkx/algorithms/dag.py", line 2, in 
    from fractions import gcd
ImportError: cannot import name 'gcd' from 'fractions' (/usr/lib/python3.10/fractions.py)

Version de Python : 3.10.7 (main, Mar 10 2023, 10:47:39) [GCC 12.2.0] 
Version de QGIS : 3.30.1-'s-Hertogenbosch 's-Hertogenbosch, 447e8d717a 

Chemin Python :
/home/jeremy/.local/share/QGIS/QGIS3/profiles/default/python/plugins/LAStools
/usr/share/qgis/python
/home/jeremy/.local/share/QGIS/QGIS3/profiles/default/python
/home/jeremy/.local/share/QGIS/QGIS3/profiles/default/python/plugins
/usr/share/qgis/python/plugins
/usr/lib/python310.zip
/usr/lib/python3.10
/usr/lib/python3.10/lib-dynload
/home/jeremy/.local/lib/python3.10/site-packages
/usr/local/lib/python3.10/dist-packages
/usr/lib/python3/dist-packages
/home/jeremy/.local/share/QGIS/QGIS3/profiles/default/python
/home/jeremy/.local/share/QGIS/QGIS3/profiles/default/python/plugins/qgis_resource_sharing
/home/jeremy/.local/share/QGIS/QGIS3/profiles/default/python/plugins/qgis_resource_sharing/ext_libs
/home/jeremy/.local/share/QGIS/QGIS3/profiles/default/python/plugins/mmqgis/forms
/home/jeremy/.local/share/QGIS/QGIS3/profiles/default/python/plugins/vector_tiles_reader/ext-libs
/home/jeremy/.local/share/QGIS/QGIS3/profiles/default/python/plugins/qgis2web
/home/jeremy/.local/share/QGIS/QGIS3/profiles/default/python/plugins
/home/jeremy/carto/carto-ndls_hors-ligne/2023
/home/jeremy/.local/share/QGIS/QGIS3/profiles/default/python/plugins/chinesepostman/lib/networkx-1.7-py2.7.egg
SoundClash2 commented 1 year ago

gcd on fractions are deprecated Change fractions in dag.py to math

Edit: someone showed it in https://github.com/rkistner/chinese-postman/issues/25