Skip to content

Loading…

GTK segfault with GTK3 and mpl_toolkits #1813

Merged
merged 2 commits into from

3 participants

@timovwb

Something goes wrong when using a GTK3 backend and the mpl_toolkits. See this very minimal testcase:

>>> from gi.repository import Gtk
>>> import mpl_toolkits.axisartist
/usr/lib/python2.7/dist-packages/gobject/constants.py:24: Warning: g_boxed_type_register_static: assertion `g_type_from_name (name) == 0' failed
  import gobject._gobject
/usr/lib/python2.7/dist-packages/gtk-2.0/gtk/__init__.py:40: Warning: specified class size for type `PyGtkGenericCellRenderer' is smaller than the parent type's `GtkCellRenderer' class size
  from gtk import _gtk
/usr/lib/python2.7/dist-packages/gtk-2.0/gtk/__init__.py:40: Warning: g_type_get_qdata: assertion `node != NULL' failed
  from gtk import _gtk
Segmentatiefout (geheugendump gemaakt)

Most likely, something imports the old GTK2 bindings, run following for the same error:

>>> from gi.repository import Gtk
>>> import gtk

Grepping the sourcecode gives mpl_toolkits/gtktools.py where it is used, but I can't even find where it is imported.

@mdboom
Matplotlib Developers member

This looks as if you do not have the development files for Gtk3 installed. Would you mind testing the attached patch? It should give you an error message to this effect.

@efiring efiring commented on an outdated diff
lib/matplotlib/backends/backend_gtk3.py
@@ -4,6 +4,16 @@
def fn_name(): return sys._getframe(1).f_code.co_name
try:
+ import gi
+except ImportError:
+ raise ImportError("Gtk3 backend requires pygobject to be installed.")
+
+try:
+ gi.require_version("Gtk", "3.0")
+except ValueError:
+ raise ImportError("Gtk3 backend gtk3 development files to be installed.")
@efiring Matplotlib Developers member
efiring added a note

Missing word: "requires".
Also, this has me puzzled, because I can run the gtk3agg backend on ubuntu Precise, but I don't have the libgtk-3-dev package installed.

@mdboom Matplotlib Developers member
mdboom added a note

It seems things are packaged somewhat differently on Debian/Ubuntu than on Fedora. I think on Ubuntu, the required package is: gir1.2-gtk3.0 https://launchpad.net/ubuntu/precise/+package/gir1.2-gtk-3.0

Since we don't really know what distro the user will be using, I'm inclined to change this to:

"The Gtk3 backend requires that the GObject introspection bindings for Gtk 3 are installed."

That should give a user enough to Google something by.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@mdboom mdboom merged commit dd38945 into matplotlib:master
@mdboom mdboom deleted the mdboom:gtk3-version-check branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 20, 2013
  1. @mdboom
Commits on May 28, 2013
  1. @mdboom
Showing with 13 additions and 1 deletion.
  1. +13 −1 lib/matplotlib/backends/backend_gtk3.py
View
14 lib/matplotlib/backends/backend_gtk3.py
@@ -4,9 +4,21 @@
def fn_name(): return sys._getframe(1).f_code.co_name
try:
+ import gi
+except ImportError:
+ raise ImportError("Gtk3 backend requires pygobject to be installed.")
+
+try:
+ gi.require_version("Gtk", "3.0")
+except ValueError:
+ raise ImportError(
+ "Gtk3 backend requires the GObject introspection bindings for Gtk 3 "
+ "to be installed.")
+
+try:
from gi.repository import Gtk, Gdk, GObject
except ImportError:
- raise ImportError("GTK3 backend requires pygobject to be installed.")
+ raise ImportError("Gtk3 backend requires pygobject to be installed.")
import matplotlib
from matplotlib._pylab_helpers import Gcf
Something went wrong with that request. Please try again.