This is a short python script:
import matplotlib.pyplot as plt
import networkx as nx
from networkx.drawing.nx_agraph import graphviz_layout
G = nx.DiGraph()
when it is executed by plain python it gave the following stacktrace:
Traceback (most recent call last):
File "python/spikes/networkx.py", line 17, in <module>
import networkx as nx
File "/home/peng/git/mxnet-spike/python/spikes/networkx.py", line 18, in <module>
from networkx.drawing.nx_agraph import graphviz_layout
ModuleNotFoundError: No module named 'networkx.drawing'; 'networkx' is not a package
What could possibly cause this? Is python interpreter defective?
You have named your file networkx.py
. When importing networkx
the local file has precedence over the installed package.
Just rename your networkx.py
and make sure to delete your __pycache__
folder if there is one.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.