Support for GTK2 backends broken (18.04 bionic)

Bug #1785458 reported by John Pye
26
This bug affects 5 people
Affects Status Importance Assigned to Milestone
matplotlib (Ubuntu)
Confirmed
Undecided
Unassigned

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:

ipython
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':

/usr/lib/python2.7/dist-packages/matplotlib/backends/_backend_gdk.x86_64-linux-gnu.so

It seems that the Build-Depends for python-matplotlib should perhaps include python-gtk2-dev in order to resolve this problem:
https://stackoverflow.com/questions/14346090/importerror-no-module-named-backend-gdk

*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/pylab.py in <module>()
----> 1 from matplotlib.pylab import *
      2 import matplotlib.pylab
      3 __doc__ = matplotlib.pylab.__doc__

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

/usr/lib/python2.7/dist-packages/matplotlib/pyplot.py in <module>()
    114 ## Global ##
    115
--> 116 _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
    117
    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)
     61
     62 # Things we pull in from all backends

/usr/lib/python2.7/dist-packages/matplotlib/backends/backend_gtkagg.py 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/backend_gtk.py in <module>()
     33 TimerBase, cursors)
     34
---> 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/backend_gdk.py 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
     34
     35 backend_version = "%d.%d.%d" % gtk.pygtk_version

ImportError: No module named _backend_gdk

Revision history for this message
John Pye (jdpipe) wrote :

I had a go a patching matplotlib so that the python2 package would at least contain the GTK backends.
https://launchpad.net/~jdpipe/+archive/ubuntu/ppa/+packages

Revision history for this message
Launchpad Janitor (janitor) wrote :

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

Changed in matplotlib (Ubuntu):
status: New → Confirmed
Revision history for this message
Pacho Ramos (pacho) wrote :

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

Revision history for this message
alirio (roly128) wrote :

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

Revision history for this message
Bert Driehuis (driehuis) wrote :

Upstream package maintainer dropped it because GTK2 is deprecated:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=889137#10

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

Revision history for this message
jobal (jobal) wrote :

Thanks John!

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

Other bug subscribers

Remote bug watches

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