I cannot make Python3 work with GTK3. I'm in a cluster context and I had everything recompiled from the sources.
When I run a simple example :
from gi.repository import Gtk
win = Gtk.Window()
win.connect("delete-event", Gtk.main_quit)
win.show_all()
Gtk.main()
I have the following error :
ERROR:root:Could not find any typelib for Gtk
Traceback (most recent call last):
File "gtk3_example.py", line 2, in
from gi.repository import Gtk
ImportError: cannot import name 'Gtk'
The problem is due to the compiled version of GTK3 that was not referenced in gobject-introspection.
It is simple to check the problem by listing the
.typelibfiles in gobject-introspection$ which g-ir-scanner /Produits/publics/x86_64.Linux.RH6/gobject-introspection/1.40.0/bin/g-ir-scanner $ ls /Produits/publics/x86_64.Linux.RH6/gobject-introspection/1.40.0/lib/girepository-1.0/ cairo-1.0.typelib fontconfig-2.0.typelib GIRepository-2.0.typelib GModule-2.0.typelib win32-1.0.typelib xlib-2.0.typelib DBus-1.0.typelib freetype2-2.0.typelib GL-1.0.typelib GObject-2.0.typelib xfixes-4.0.typelib xrandr-1.3.typelib DBusGLib-1.0.typelib Gio-2.0.typelib GLib-2.0.typelib libxml2-2.0.typelib xft-2.0.typelibThe problem should be solved by recompiling GTK (and its dependencies) with the configure option
--enable-introspection=yes.