如何让matplotlib使用后端拉入Gtk3?

时间:2017-02-12 10:21:43

标签: python python-3.x matplotlib gtk gtk3

我正在使用graph-tool python包进行一些分析。在分析过程中,我试图绘制一些情节。但是,这是一个错误:

(ipython:2926): Gtk-ERROR **: GTK+ 2.x symbols detected. Using GTK+ 2.x and GTK+ 3 in the same process is not supported
Trace/breakpoint trap (core dumped)

我向开发人员询问了这个问题,他告诉了我:

GTK 2 and 3 cannot be used in the same program. GTK 3 is used by graph-tool,
and it seems you are using a matplotlib backend that pulls in GTK 2. You
need to use another backend, e.g. GTK3Cairo.

我无法理解如何做到这一点。我试过搜索,我在stackoverflow上得到了一些相关的问题。但是,它们并没有解决我的问题。官方matplotlib页面上的instructions对我来说也是无法理解的。有人可以帮我这个吗?

1 个答案:

答案 0 :(得分:0)

  1. 在您的主目录中创建一个目录'.matplotlib'
  2. 在这个'.matplotlib'目录中,你用一行创建一个'matplotlibrc'文件:

    后端:GTK3Cairo

  3. 我不确定白色空间是否重要,但无论如何情况并不重要。

    这是官方的matplotlib解决方案。什么是'难以理解'的意思:你不理解它(在这种情况下,我希望这有帮助),或者它不起作用?