Importing graph_tool.all breaks if Gtk isn't available but GObject is
The error:
> import graph_tool.all as gt
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Input In [2], in <cell line: 1>()
----> 1 import graph_tool.all as gt
File /gnu/store/dkw4m4ygvh9fkw8jp5wzj2bkb9dhb01d-profile/lib/python3.9/site-packages/graph_tool/all.py:34, in <module>
32 import graph_tool.centrality
33 try:
---> 34 from graph_tool.draw import *
35 import graph_tool.draw
36 except ImportError as e:
37 # Proceed despite errors with cairo, matplotlib, etc.
File /gnu/store/dkw4m4ygvh9fkw8jp5wzj2bkb9dhb01d-profile/lib/python3.9/site-packages/graph_tool/draw/__init__.py:848, in <module>
845 return prop
847 try:
--> 848 from . cairo_draw import graph_draw, cairo_draw, \
849 get_hierarchy_control_points, default_cm, default_clrs, draw_hierarchy
850 __all__ += ["draw_hierarchy"]
851 except ImportError:
File /gnu/store/dkw4m4ygvh9fkw8jp5wzj2bkb9dhb01d-profile/lib/python3.9/site-packages/graph_tool/draw/cairo_draw.py:1494, in <module>
1492 try:
1493 import gi
-> 1494 gi.require_version('Gtk', '3.0')
1495 from gi.repository import Gtk, Gdk, GdkPixbuf
1496 from gi.repository import GObject as gobject
File /gnu/store/da3ki5vd9shsdrpabw022rkf8v4bpkza-python-pygobject-3.40.1/lib/python3.9/site-packages/gi/__init__.py:126, in require_version(namespace, version)
124 available_versions = repository.enumerate_versions(namespace)
125 if not available_versions:
--> 126 raise ValueError('Namespace %s not available' % namespace)
128 if version not in available_versions:
129 raise ValueError('Namespace %s not available for version %s' %
130 (namespace, version))
ValueError: Namespace Gtk not available
A simple fix would be to change cairo_draw.py:1498
to:
except (ImportError, RuntimeError, ValueError) as e: