Skip to content

Commit b105ab2

Browse files
authored
Merge pull request #12929 from tacaswell/fix_gtk_failure
FIX: skip gtk backend if gobject but not pygtk is installed
2 parents 13c6d88 + a583488 commit b105ab2

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lib/matplotlib/backends/_gtk3_compat.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,15 @@
4040

4141
if gi.__name__ == "pgi" and gi.version_info < (0, 0, 11, 2):
4242
raise ImportError("The GTK3 backends are incompatible with pgi<0.0.11.2")
43-
gi.require_version("Gtk", "3.0")
43+
try:
44+
# :raises ValueError: If module/version is already loaded, already
45+
# required, or unavailable.
46+
gi.require_version("Gtk", "3.0")
47+
except ValueError as e:
48+
# in this case we want to re-raise as ImportError so the
49+
# auto-backend selection logic correctly skips.
50+
raise ImportError from e
51+
4452
globals().update(
4553
{name:
4654
importlib.import_module("{}.repository.{}".format(gi.__name__, name))

0 commit comments

Comments
 (0)