栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

使用networkx画图时,报错:AttributeError: module ‘scipy.sparse’ has no attribute ‘coo

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

使用networkx画图时,报错:AttributeError: module ‘scipy.sparse’ has no attribute ‘coo

问题描述

使用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_InstallationAnacondaenvspytorchlibsite-packagesscipy.libslibbanded5x.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
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/938457.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号