导入matplotlib包出现各种错误的解决方法

导入matplotlib包是出现各种错误,解决一个又出现一个。比如:module ‘matplotlib’ has no attribute ‘get_data_path’,No module named ‘pyparsing’, cannot import name ‘get_versions’ from ‘matplotlib._version’等等。在网上大多数都是重新安装matplotlib包,然而也没有解决。

这个错误可能是由于Matplotlib的版本不兼容导致的,与你Python版本或者其他包(numpy,scipy)版本不兼容问题。

解决方法:

1、在终端Anaconda Prompt(切换到运行Python的环境下),激活环境。

2、删除numpy,scipy,matplotlib包(最好是按顺序)。

pip uninstall numpy,pip uninstall numpy,pip uninstall matplotlib

3、重新安装numpy,scipy,matplotlib包(最好是按顺序)

利用清华镜像:

pip install numpy -i https://pypi.tuna.tsinghua.edu.cn/simple

pip install scipy -i https://pypi.tuna.tsinghua.edu.cn/simple

pip install matplotlib -i https://pypi.tuna.tsinghua.edu.cn/simple

最后重新导入matplotlib,导入成功!!!(花了我一小时导入

 

文章出处登录后可见!

已经登录?立即刷新

共计人评分,平均

到目前为止还没有投票!成为第一位评论此文章。

(0)
xiaoxingxing的头像xiaoxingxing管理团队
上一篇 2023年9月6日
下一篇 2023年9月6日

相关推荐