如何让 matplotlib 使用拉入 Gtk3 的后端?
How to make matplotlib use backend that pulls in 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.
我不明白该怎么做。我尝试搜索,但在 Whosebug 上几乎没有遇到相关问题。但是,它们不能解决我的问题。 matplotlib 官方页面上的 instructions 我也看不懂。有人可以帮我解决这个问题吗?
- 在您的主目录中创建目录“.matplotlib”
在这个“.matplotlib”目录中,您创建一个文件'matplotlibrc',其中包含一行:
后端:GTK3Cairo
我不确定空格是否重要,但无论如何大小写无关紧要。
这是官方的 matplotlib 解决方案。 'unintelligible' 是什么意思:您不明白(在这种情况下,我希望这有帮助),或者它没有用?
我正在使用 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.
我不明白该怎么做。我尝试搜索,但在 Whosebug 上几乎没有遇到相关问题。但是,它们不能解决我的问题。 matplotlib 官方页面上的 instructions 我也看不懂。有人可以帮我解决这个问题吗?
- 在您的主目录中创建目录“.matplotlib”
在这个“.matplotlib”目录中,您创建一个文件'matplotlibrc',其中包含一行:
后端:GTK3Cairo
我不确定空格是否重要,但无论如何大小写无关紧要。
这是官方的 matplotlib 解决方案。 'unintelligible' 是什么意思:您不明白(在这种情况下,我希望这有帮助),或者它没有用?