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

Cod*_*uch 7 python importerror networkx anaconda

from networkx import *
import matplotlib.pyplot as plt
Run Code Online (Sandbox Code Playgroud)

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'
Run Code Online (Sandbox Code Playgroud)

小智 5

我刚才也有同样的问题。似乎是因为我在 py 文件导入 networkx 时使用了Ctrl+ c。所以我关闭环境并重新启动。那时一切正常。