from fractions import gcd 修改为: python from math import gcd 如果修改后仍然出现错误,检查Python环境或安装相关依赖: 由于gcd 是Python标准库 math 模块的一部分,通常不需要额外安装依赖。如果修改导入语句后仍出现错误,请检查你的Python环境是否正常,或者尝试在不同的Python环境中运行代码(例如,使用虚拟环境)。
I had the same output. In my case was resolved to comment in /usr/local/lib/python3.9/dist-packages/networkx/algorithms/dag.pyfrom fractions import gcdand writingimport math. And editing in codeg = gcd(g, levels[u] - levels[v] + 1)byg = math.gcd(g, levels[u] - levels[v] + 1)...
in __init__ exec("import %s"%(name)) File "<string>", line 1, in <module> File "/home/kvin/codes/cnc/bCNC/bCNC/plugins/spirograph.py", line 20, in <module> from fractions import gcd ImportError: cannot import name 'gcd' from 'fractions' (/usr/local/lib/python3.9/fractions.py)...