Error "Could not find any typelib for Gtk" with Python3 and GTK3

Michael Dussere picture Michael Dussere · Jul 30, 2014 · Viewed 7k times · Source

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'

Answer

dragon788 picture dragon788 · May 1, 2016

There are typically additional packages to install depending on what you want to introspect. The one I found that was crucial was gir1.2-gtk-3.0 (or 2.0 depending which version you are coding against).