Importing Gtk typelib for Python on KDE

690 views Asked by At

I have written a GUI application in python making use of Gtk. Unfortunately I had to move to a new OS and absolutely have to use its KDE desktop.

Now python can not import any of the submodules from gi.repository, despite python-gi being installed and up to date:

from gi.repository import Gtk, GObject, GLib

It seems to be a general problem on Linux, that any submodule references of gi.repository can not be resolved but strangely enough the python GUI was still executable and ran flawlessly on all Gnome systems (Ubuntu, Lubuntu, Linux Mint) I tested it on.

Not so on KDE. Running the code yields the following error:

ERROR:root:Could not find any typelib for Gtk
Traceback (most recent call last):
  File "folder/Program.py", line 2, in <module>
    from gi.repository import Gtk, GObject, GLib
ImportError: cannot import name Gtk

I am a bit lost how to overcome this error. I think I have to install some Gtk system packages/typelib, but which?

Could not find anything on the web.

Any suggestions are warmly welcome!

Info: I am running on Debian Wheezy with KDE.

1

There are 1 answers

0
andlabs On BEST ANSWER

The answer differs per distribution; for instance, on Debian/Ubuntu-based systems, you have to install gir1.2-gtk-[23].0 depending on which GTK+ version you want to target as well as the appropriate libgtk*-dev for that version. (At least I think; I'm not sure if they both need to be installed for Python or not...).