Support for GTK2 backends broken (18.04 bionic)

Bug #1785458 reported by John Pye on 2018-08-05
This bug affects 5 people
Affects Status Importance Assigned to Milestone
matplotlib (Ubuntu)

Bug Description

As of 18.04, it seems that support for the GTKCairo and GTKAgg (GTK2) backends for matplotlib (2.1.1-2ubuntu3) are broken.

To demonstrate, the following runs without error on 16.04, but produces error messages (see below*) on 18.04:

import matplotlib; matplotlib.use('GTKAgg')
import pylab

The final error message is "ImportError: No module named _backend_gdk". It is clear that the _backend_gdk file is not provided in the python-matplotlib package, whereas it was in Ubuntu 16.04; see below from 'dpkg -L python-matplotlib':


It seems that the Build-Depends for python-matplotlib should perhaps include python-gtk2-dev in order to resolve this problem:

*Error messages note above:

Gtk-Message: 17:45:01.751: Failed to load module "canberra-gtk-module"

(ipython:10617): dbind-WARNING **: 17:45:01.756: Couldn't register with accessibility bus: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.
ImportError Traceback (most recent call last)
<ipython-input-2-a18b8f3c2edd> in <module>()
----> 1 import pylab

/usr/lib/python2.7/dist-packages/ in <module>()
----> 1 from matplotlib.pylab import *
      2 import matplotlib.pylab
      3 __doc__ = matplotlib.pylab.__doc__

/usr/lib/python2.7/dist-packages/matplotlib/ in <module>()
    255 window_hanning, window_none)
--> 257 from matplotlib import cbook, mlab, pyplot as plt
    258 from matplotlib.pyplot import *

/usr/lib/python2.7/dist-packages/matplotlib/ in <module>()
    114 ## Global ##
--> 116 _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
    118 _IP_REGISTERED = None

/usr/lib/python2.7/dist-packages/matplotlib/backends/__init__.pyc in pylab_setup(name)
     58 # imports. 0 means only perform absolute imports.
     59 backend_mod = __import__(backend_name, globals(), locals(),
---> 60 [backend_name], 0)
     62 # Things we pull in from all backends

/usr/lib/python2.7/dist-packages/matplotlib/backends/ in <module>()
     12 from matplotlib.figure import Figure
     13 from matplotlib.backends.backend_agg import FigureCanvasAgg
---> 14 from matplotlib.backends.backend_gtk import (
     15 gtk, _BackendGTK, FigureCanvasGTK, FigureManagerGTK, NavigationToolbar2GTK,
     16 backend_version, error_msg_gtk, PIXELS_PER_INCH)

/usr/lib/python2.7/dist-packages/matplotlib/backends/ in <module>()
     33 TimerBase, cursors)
---> 35 from matplotlib.backends.backend_gdk import RendererGDK, FigureCanvasGDK
     36 from matplotlib.cbook import is_writable_file_like, warn_deprecated
     37 from matplotlib.figure import Figure

/usr/lib/python2.7/dist-packages/matplotlib/backends/ in <module>()
     31 from matplotlib.mathtext import MathTextParser
     32 from matplotlib.transforms import Affine2D
---> 33 from matplotlib.backends._backend_gdk import pixbuf_get_pixels_array
     35 backend_version = "%d.%d.%d" % gtk.pygtk_version

ImportError: No module named _backend_gdk

John Pye (jdpipe) wrote :

I had a go a patching matplotlib so that the python2 package would at least contain the GTK backends.

Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in matplotlib (Ubuntu):
status: New → Confirmed
Pacho Ramos (pacho) wrote :

Just hit this bug too, thanks for John for his packages, they work nice

alirio (roly128) wrote :

Can second Pacho with the same bug here. Also John's patch worked like a charm, thousand thanks!

Bert Driehuis (driehuis) wrote :

Upstream package maintainer dropped it because GTK2 is deprecated:

Of course, the practical upshot of that decision is that Debian Sid and Ubuntu >= 17.10 ship an unusable gtkcairo matplotlib backend.

jobal (jobal) wrote :

Thanks John!

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.