简体   繁体   中英

PyGObject on Windows “ERROR:root:Could not find any typelib for Gtk”

I need help setting up PyGObject under Windows. I've installed it but I get the following error when importing Gtk and Gdk from gi.repository

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

I'm able to import gi.repository.GLib , gi.repository.Gio , gi.repository.GObject , gi.repository.cairo and cairo but I can't import gi.repository.Gtk and gi.repository.Gdk and gi.repository.GdkPixbuf .

I have tried uninstalling it from the uninstaller in add/remove programs and then reinstalling it but the error persisted.

If someone could help that would be really appreciated.

I dont know if this is the right answer but check if you have Gtk-version_number.typelib file in you installation. I had similar problem but I had this problem when I built my program with pyinstaller. I just copied .typelib files and my program worked. I dont know if this applies here but try finding that file and copying to installation sub directory where other .typelib files are.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM