Reputation: 462
I know it is a duplicate, but this hasn't solved my issue nor other guide online has.
I have installed the Anaconda distribution and it is the only Python environment I have on this computer. I always used Jupyter as Python "engine" and things worked flawlessly up until now, where I have switched to Sublime editor + CMD. I have tried to reinstall it via pip install -U networkx
and via downloading from Git and then pip install .
but none of them worked.
import networkx as nx
gr= nx.Graph()
Traceback (most recent call last):
File "networkx.py", line 1, in <module>
import networkx as nx
File "C:\Users\Utente\nx\networkx.py", line 3, in <module>
gr = nx.Graph()
AttributeError: module 'networkx' has no attribute 'Graph'
For whatever reason, using Jupyter QtConsole works, but I cannot use that to write and debug code
Upvotes: 1
Views: 4246
Reputation: 11
I was also facing this kind of issue. So, first, try to save your file as another name except for network and then run the program again and don't forget to delete the old file if it was named as network.py if you are using the same directory.
Upvotes: 0
Reputation: 4882
The problem is probably the name of your python
file. From your error message I see, your file is named networkx.py
. Rename that to something different like networks.py
will probably resolve your problem.
The import try to import your file and not the package. Since your file does not implement Graph
or __version__
an error is raised.
Upvotes: 8