使用networkx画图时,报错:AttributeError: module ‘scipy.sparse’ has no attribute ‘coo_array’
G = nx.random_graphs.barabasi_albert_graph(20, 2) # 生成一个n=1000,m=5的BA无标度网络 pos = nx.spring_layout(G) plt.title("BA free scale Network") nx.draw(G, pos, node_color="green", edge_color="red", with_labels=False, node_size=10) plt.show()
根据网上的建议,我更新了networkx和scipy包到最新版本。
但新的错误又诞生了,它告诉我文件找不到,但是该路径的文件确实存在。
FileNotFoundError: Could not find module 'D:\Software_Installation\Anaconda\envs\pytorch\lib\site-packages\scipy\.libs\libbanded5x.R5FKBI2I62BSXV4Z4HDB42UEWJ6S2M5F.gfortran-win_amd64.dll' (or one of its dependencies).
继续与bug抗争,网上说scipy的版本不对,需要修改版本为1.6.2。但是我修改后仍旧显示错误。
我知道是因为升级版本造成的。文件找不到是由于其依赖文件缺失。我在网络上查了安装scipy的教程,发现安装scipy的时候关系最大的是numpy包。于是我卸载了scipy包,更新numpy到最新版本,再安装scipy包最新版,问题迎刃而解。
conda uninstall scipy
conda upgrade numpy
conda install scipy