Michael Dussere
Michael Dussere

Reputation: 498

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.

    ** (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.

Upvotes: 1

Views: 7744

Answers (2)

Pe Dro
Pe Dro

Reputation: 3043

Installing Python binging for Python works:

$ pip install pycairo

Upvotes: 2

Roland Smith
Roland Smith

Reputation: 43533

If you look at the backend_gtk3agg.py file, you'll see that the first lines in the file are;

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. And numpy.

It uses Cairo for ImageSurface buffers, because that is something AGG does not provide. I do not know why the gtk3agg developers chose this method. Presumably because it was convenient.

Upvotes: 0

Related Questions