1

I'm on macOS, using another program needs to run python script contains networkx module. My networkx2.1 is installed using:

pip install networkx --user

The error raised is that:

File "/Users/myname/Library/Python/2.7/lib/python/site-packages/networkx/__init__.py", line 43, in <module>
import networkx as nx
ImportError
from networkx import release
cannot import name release

I've done some search on this error, and those seem working is by using the networkx of another version, or install/uninstall.

I've already tried uninstall and reinstall networkx of version 1.9, 1.5, 1.1, however this error continues.

Anyone also encounterd this issue?

Raphael Guzman
  • 220
  • 2
  • 7
Shirley Hou
  • 21
  • 1
  • 3

4 Answers4

1

There is a simple way to install networkx. please follow below steps. sudo apt-get update sudo apt-get install python-networkx

1

What helped me was using MAHENDRAN BALU solution and then reinstalling:

sudo apt-get update
sudo apt-get install python-networkx
sudo python3 -m pip uninstall networkx
sudo python3 -m pip install networkx
Gal Shahar
  • 2,695
  • 1
  • 21
  • 29
  • why is your answer so complicated? how does it compare with `conda install -y networkx">=2.5"`? – Charlie Parker Jul 19 '21 at 16:37
  • 1
    Firstly, I have written my answer a few months ago, you, yesterday. Secondly, my solution does not require conda to be installed. Moreover, that what worked for me. If you have more complaints you can find a wall and complain to it @Charlie Parker – Gal Shahar Jul 20 '21 at 19:23
1

The error may be due to using an older version. This worked for me:

pip install networkx --force-reinstall --no-deps --upgrade --user
cconsta1
  • 737
  • 1
  • 6
  • 20
0

if you want a specific version do:

conda install -y networkx">=2.5"

sometims -c conda-forge is useful (but not always recommended?)...

Charlie Parker
  • 5,884
  • 57
  • 198
  • 323