我之前在openSUSE(12.3)上也见过。解决方法是编辑默认的matplotlibrc文件。
这是查找默认matplotlibrc文件的位置以及在我的计算机上的位置的方法:
>>> import matplotlib>>> matplotlib.matplotlib_fname()'/usr/lib64/python2.7/site-packages/matplotlib/mpl-data/matplotlibrc'
后端设置是此文件中的第一个配置选项。将其从更改
TkAgg为
Agg,或更改为系统上已安装的其他后端。matplotlibrc文件中的注释列出了matplotlib支持的所有后端。
此文件中指定的后端仅是默认值。您仍然可以在运行时通过 在其他matplotlib导入之前 添加以下两行来更改它:
import matplotlibmatplotlib.use("Agg") # or whichever backend you wish to use


