解决python报错:AttributeError: module ‘matplotlib.cm‘ has no attribute ‘spectral‘

最开始以为是matplotlib的版本问题,于是关闭文件进行了版本更新(不关闭python文件直接在命令行输入pip install --upgrade matplotlib会报错:

解决python报错:AttributeError: module ‘matplotlib.cm‘ has no attribute ‘spectral‘_第1张图片

Could not install packages due to an OSError: [WinError 32] 另一个程序正在使用此文件,进程无法访问。: '这里一堆路径,是在python文件中用到的font等等` option or check the permissions.

安装最新版本后,检查matplotlib版本,确认为最新。

但系试运行代码依旧会报错。查阅资料后发现,是由于2.2以上的matplotlib版本对于spectral的调用函数发生了变化:

2.2以上matplotlib版本如何调用spectralicon-default.png?t=N7T8https://github.com/bee-hive/MedGP/issues/3

原代码为:
解决python报错:AttributeError: module ‘matplotlib.cm‘ has no attribute ‘spectral‘_第2张图片

应当改为:

代码成功运行。

问题解决!

你可能感兴趣的:(实训期间报错整理,python,matplotlib,开发语言)