我正在尝试从networkx导入发布,但我在ipython笔记本上遇到了以下错误。 我已成功安装networkx。 有人可以帮忙吗?
代码:
import networkx as nx
from networkx import release
print "NetworkX version: %6.6s (need at least 1.7)" % nx.__version__
错误:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-12-675a5f60bf8e> in <module>()
28
29 # Networkx is a library for working with networks
---> 30 import networkx as nx
31 from networkx import release
32 print "NetworkX version: %6.6s (need at least 1.7)" % nx.__version__
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/networkx/__init__.py in <module>()
41
42 # Release data
---> 43 from networkx import release
44
45 __author__ = '%s <%s>\n%s <%s>\n%s <%s>' % \
ImportError: cannot import name release
答案 0 :(得分:2)
导入networkx 1.9.1时出现同样的错误。只需重新安装就可以解决问题。
pip uninstall networkx && pip install networkx
答案 1 :(得分:0)
只需打开cmd并运行此命令
python -m pip install networkx --upgrade pip