question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ImportError: cannot import name 'gcd' from 'fractions' (/usr/lib/python3.9/fractions.py)

See original GitHub issue

Please provide a description of the issue and any relevant error messages. When python3 ./sf.py -l 127.0.0.1:5001 is executed , i get the below error.

I have installed gcd and also added PATH to .profile

Stack Trace

Traceback (most recent call last): File “/home/user1/Desktop/user2/OSINT/spiderfoot-3.2.1/./sf.py”, line 30, in <module> from sflib import SpiderFoot File “/home/user1/Desktop/user2/OSINT/spiderfoot-3.2.1/sflib.py”, line 40, in <module> from networkx import nx File “/home/user1/.local/lib/python3.9/site-packages/networkx/init.py”, line 114, in <module> import networkx.generators File “/home/user1/.local/lib/python3.9/site-packages/networkx/generators/init.py”, line 14, in <module> from networkx.generators.intersection import * File “/home/user1/.local/lib/python3.9/site-packages/networkx/generators/intersection.py”, line 13, in <module> from networkx.algorithms import bipartite File “/home/user1/.local/lib/python3.9/site-packages/networkx/algorithms/init.py”, line 16, in <module> from networkx.algorithms.dag import * File “/home/user1/.local/lib/python3.9/site-packages/networkx/algorithms/dag.py”, line 23, in <module> from fractions import gcd ImportError: cannot import name ‘gcd’ from ‘fractions’ (/usr/lib/python3.9/fractions.py)

What version of Python are you using?

Python 3.9

What version of SpiderFoot are you using (stable release or Git master branch)?

Stable

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:17 (5 by maintainers)

github_iconTop GitHub Comments

9reactions
LexusMindercommented, Dec 28, 2020

I had the same output. In my case was resolved to comment in /usr/local/lib/python3.9/dist-packages/networkx/algorithms/dag.py from fractions import gcd and writing import math.

And editing in code g = gcd(g, levels[u] - levels[v] + 1) by g = math.gcd(g, levels[u] - levels[v] + 1)

This are the changes was made in my case

3reactions
bcolescommented, Jan 22, 2021

Duplicate of #1111.

Run pip3 install -r requirements.txt or pip3 install networkx==2.5.

This issue is due to the networkx package using a function which is now deprecated and not available in Python 3.9. This has been resolved in networkx version 2.5.

Spiderfoot specifies networkx version 2.5 or newer in requirements.txt :

https://github.com/smicallef/spiderfoot/blob/4ffad6a9b130d0e6d40b35a7047229a41102080f/requirements.txt#L23

Read more comments on GitHub >

github_iconTop Results From Across the Web

Import Error: can't import name gcd from fractions
fractions.gcd(a, b) has been moved to math.gcd(a, b) in Python 3.9. In fact it has been deprecated in Python 3.5 already (in brackets): ......
Read more >
ImportError: cannot import name 'gcd' from 'fractions'
The "ImportError: cannot import name 'gcd' from 'fractions'" occurs because the gcd() method has been moved to the math module starting Python ......
Read more >
cannot import name 'gcd' from 'fractions'
Hello. It seems that in Python 3.9 gcd function is in module math not fractions. You can either trace back the error and...
Read more >
1932056 – Python3-libs error on fractions.py module
... in <module> ImportError: cannot import name 'gcd' from 'fractions' (/usr/lib64/python3.9/fractions.py) Expected results: Loads module ...
Read more >
version graph
Subject: libxcb: FTBFS: ImportError: cannot import name 'gcd' from 'fractions' (/usr/lib/python3.9/fractions.py).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found