[python error resolution] AttributeError: module 'networkx' has no attribute 'Graph'

Use the networkx library

To create an undirected graph, use the function
import networkx as nx
G=nx.Graph()

I get an error: AttributeError: module 'networkx' has no attribute 'Graph'

Solution:
In the site-packages folder in the python installation package (the author's file path: C:\Users\Anaconda3\Lib\site-packages), copy the entire networkx folder to the folder where the running program is located. can function correctly.

Guess you like

Origin blog.csdn.net/weixin_41824534/article/details/108422641