简体   繁体   English

Matplotlib 后端 GTK3 Agg 使用开罗?

[英]Matplotlib backend GTK3 Agg using Cairo?

I don't understand why while I' trying to use the Gtk3Agg backend and I end up with an error telling me the cairo module is not found.我不明白为什么当我尝试使用 Gtk3Agg 后端时,我最终得到一个错误,告诉我找不到 cairo 模块。

** (simple_plot_in_gtk3.py:312517): WARNING **: Error retrieving accessibility bus address: org.freedesktop.DBus.Error.ServiceUnknown: The name org.a11y.Bus was not provided by any .service files
    Traceback (most recent call last):
      File "simple_plot_in_gtk3.py", line 5, in 
        from matplotlib.backends.backend_gtk3agg import FigureCanvasGTK3Agg as FigureCanvas
      File "/Produits/publics/x86_64.Linux.RH6/python/3.4.1/lib/python3.4/site-packages/matplotlib-1.3.1-py3.4-linux-x86_64.egg/matplotlib/backends/backend_gtk3agg.py", line 1, in 
        import cairo
    ImportError: No module named 'cairo'

I'm trying to run the matplotlib/GTK3 example from matplolib site.我正在尝试从 matplolib 站点运行matplotlib/GTK3 示例

If you look at the backend_gtk3agg.py file, you'll see that the first lines in the file are;如果您查看backend_gtk3agg.py文件,您会看到文件中的第一行是;

import cairo
import numpy as np
import sys
import warnings

import backend_agg
import backend_gtk3
from matplotlib.figure import Figure
from matplotlib import transforms

So, yes, the gtk3agg backend requires the cairo library and its Python bindings .所以,是的,gtk3agg 后端需要cairo 库及其Python 绑定 And numpy.和麻木。

It uses Cairo for ImageSurface buffers, because that is something AGG does not provide .它使用 Cairo 作为 ImageSurface 缓冲区,因为这是 AGG 不提供的 I do not know why the gtk3agg developers chose this method.不知道为什么 gtk3agg 的开发者选择了这种方式。 Presumably because it was convenient.大概是因为方便吧。

为 Python安装Python binging工作:

$ pip install pycairo

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM