[英]Why do I get a TypeError: 'module' object is not callable when trying to import the random module?
[英]TypeError: 'module' object is not callable for anaconda when I am trying to import networkx
我尝试导入networkx模块时收到此错误
import networkx as nx
G=nx.graph()
G.add_node(1)
堆栈跟踪为
TypeError Traceback (most recent call last)
<ipython-input-8-11d4167b2e44> in <module>()
1 from networkx import networkx
----> 2 G=nx.graph()
3 G.add_node(1)
TypeError: 'module' object is not callable
当我尝试在具有conda根环境的jupyter笔记本上运行此程序时发生了这种情况,尽管在该环境中安装了networkx
您需要使用Graph
而不是graph
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.