Reputation: 81
from networkx import *
import matplotlib.pyplot as plt
I've imported the networkx library which previously (yesterday) allowed me to create a random graph. Running the same code again today I'm getting import errors. I am using this on Jupyter notebook/Anaconda Python.
AttributeError Traceback (most recent call last)
<ipython-input-13-d245e6f3c125> in <module>()
----> 1 from networkx import *
2 import matplotlib.pyplot as plt
C:\Anaconda3\lib\site-packages\networkx\__init__.py in <module>()
96 from networkx.tests.test import run as test
97
---> 98 import networkx.drawing
99 from networkx.drawing import *
C:\Anaconda3\lib\site-packages\networkx\drawing\__init__.py in <module>()
3 from .layout import *
4 from .nx_pylab import *
----> 5 from . import nx_agraph
6 from . import nx_pydot
C:\Anaconda3\lib\site-packages\networkx\drawing\nx_agraph.py in <module>()
272 return node_pos
273
--> 274 @nx.utils.open_file(5, 'w')
275 def view_pygraphviz(G, edgelabel=None, prog='dot', args='',
276 suffix='', path=None):
AttributeError: module 'networkx' has no attribute 'utils'
Upvotes: 7
Views: 8060
Reputation: 355
I too had the same problem. Had named the file as networkx.py and ran the code to find that the same error pops up. Turned out I had to rename the file (networkx_1.py) and the error was no longer there. Hope it helps.
Upvotes: 0
Reputation: 61
I had to restart the kernel in my jupyter notebook and now it works.
Upvotes: 2
Reputation: 23
This module is imported once. Usually the promblem in Jypyter Notebook
Try to reload your .ipy file (or notebooke)
Upvotes: 0
Reputation: 51
I have the same quesion just now. It seems like it's because I use Ctrl+c while the py file is import the networkx. So I close the environment and restart again. Everything is normal then.
Upvotes: 5