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