Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AttributeError: module 'networkx' has no attribute 'utils'

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'
like image 525
CodeMuch Avatar asked Apr 10 '18 13:04

CodeMuch


2 Answers

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.

like image 70
Shawn Avatar answered Oct 19 '22 13:10

Shawn


I had to restart the kernel in my jupyter notebook and now it works.

like image 2
Pascal KREZEL Avatar answered Oct 19 '22 11:10

Pascal KREZEL