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

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

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 17 (5 by maintainers)

Commits related to this issue

Most upvoted comments

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

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

this worked for me:

conda install -y networkx">=2.5"