linux下python3.4配置matplotlib的问题

来源:互联网 发布:淘宝直通车图片大小 编辑:程序博客网 时间:2024/06/06 10:06
安装
在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 matplotlibmatplotlib.matplotlib_fname() 

结果就是matplotlib的配置文件matplotlibrc

编辑这个文件
把其中的backend : Gtk3Agg改成backend:TkAgg
当然这个前提 是你在机器上装过Tk的库

或者
把其中的backend : Gtk3Agg改成backend:qt5agg
这个也是要装点东西的..

sudo apt-get install python3-pyqt5

然后就可以完美运行

0 0