安装
在ubuntu下,直接apt-get install python3-matplotlib就安装了.
问题
但是我在执行
import matplotlib.pyplot as plt
会出现一个问题
The Gtk3Agg backend is known to not work on Python 3.x with pycairo
在stackoverflow查到了解决方案
先在python中执行
import matplotlib
matplotlib.matplotlib_fname()
结果就是matplotlib的配置文件matplotlibrc
编辑这个文件
把其中的backend : Gtk3Agg改成backend:TkAgg
当然这个前提 是你在机器上装过Tk的库
或者
把其中的backend : Gtk3Agg改成backend:qt5agg
这个也是要装点东西的..
sudo apt-get install python3-pyqt5
然后就可以完美运行