Ubuntu16.04安装matplotlib出现的问题

问题描述:

在spyder中import matplotlib,出现错误:can not import name cbook

在jupyter notebook中import matplotlib,出现错误:No module named functools_lru_cache


解决办法:

这个解决办法搞得我也很费解。因为在配置caffe2的过程中我已经通过命令:sudo pip install matplotlib,安装了matplotlib(具体的版本好象是2.2.2)但是经过百度说这种方式是错误的。所以首先第一步就是先卸载,

1.卸载已经下载的matplotlib

sudo pip uninstall matplotlib

2.再利用命令 sudo apt-get install python-matplotlib安装,却又提示:python-matplotlib 已经是最新版 (1.5.1-1ubuntu1),那咋本呢,接着卸载呗

3.利用命令 sudo apt-get autoremove python-matplotlib,完全删除包

4.最后再运行:sudo apt-get install python-matplotlib,即可正确安装matplotlib。


后续:

之后因为其他原因又要安装scikit-image包,然后百度的命令是 sudo pip install scikit-image,安装完毕后运行,又出现上面的问题,can not import name cbook。

没有办法只能先卸载了scikit-image(sudo pip uninstall scikit-image),之后还是报相同的错误,抱着试一试的态度想着难道又是matplotlib惹的祸?通过sudo pip uninstall matplotlib,果然又卸掉了一些东西,看来是安装scikit-image的过程中,又默认安装了一些。

最后通过sudo apt-get install python-skimage,安装成功了也没有再报错。

然后就想,难道必须用第二种方式(sudo apt-get install python-skimage)才能安装相应的包么,搞不懂诶。


最后补充一些命令感觉以后会用到:

sudo apt-get install python-numpy python-scipy python-matplotlib python-sklearn python-skimage python-h5py python-protobuf python-leveldb python-networkx python-nose python-pandas python-gflags Cython ipython

猜你喜欢

转载自blog.csdn.net/Mr_health/article/details/80659019