一、问题概述
使用 ​​​conda install matplotlib​​​ 命令安装 ​​matplotlib​​​ 进虚拟环境,但是使用时报各种错误(缺少各种包,例如:​​packageparsing​​​、​​cycler​​​、​​six​​​ 等)
二、解决办法
1、卸载虚拟环境中的 ​​​matplotlib​

conda remove matplotlib

卸载完毕后,再次使用 ​​conda list matplotlib​​​ 查询虚拟环境中是否还有其他版本的 ​​matplotlib​​​ ,若有,则继续用上述命令卸载。
2、在虚拟环境中使用 pip 命令安装 ​​​matplotlib​​​ 首先使用 ​​pip -V​​ 查询当前使用的 pip 是不是虚拟环境中的 pip(命令执行后会显示当前 pip 的路径,若不是虚拟环境路径,则说明虚拟环境中无 pip),若不是,则需要在虚拟环境中装上 pip,命令如下:

conda install pip

安装完毕后,则使用 ​​pip​​​ 命令安装 ​​matplotlib​​,命令如下:

pip install matplotlib==3.5.3 -i http://pypi.douban.com/simple --trusted-host pypi.douban.com

3、测试 ​​matplotlib​​​ 若在使用 ​​matplotlib​​ 时,报错如下:

Matplotlib:module backend_interagg has no attribute FigureCanvas

则说明当前的 ​​matplotlib​​​ 版本过高,需要指定 matplotlib 低版本,我在上面就指定了版本,​​matplotlib==3.5.3​​,我的程序就不报错了。