How to fix ModuleNotFoundError: No module named 'networkx.drawing'; 'networkx' is not a package

后端 未结 1 920
甜味超标
甜味超标 2021-01-27 08:30

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()
         


        
1条回答
  •  旧时难觅i
    2021-01-27 09:06

    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.

    0 讨论(0)
提交回复
热议问题