I am new to python and trying to run a program with Gtk on Python 3.4 and Windows 7.
I installed Python 3.4, the GTK+ all-in-one-bundle for Windows and PyGObject (which your are apparently supposed to use with Python 3+ now).
However, I am always getting the same error when trying to import Gtk:
C:\>python -c "from gi.repository import Gtk"
The error is
ERROR:root:Could not find any typelib for Gtk
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: cannot import name 'Gtk'
Is there any essential step I am missing? I could not find any information on that problem, most advice is unix-related and advises people to install this or that debian package. (Which does not help me much on a Win 7 machine.)
I finally got it to work by adding an environment variable named "GTK_BASEPATH" pointing to the GTK+ main folder and reinstalling PyGObject with all packages that looked useful to me.
My guess is that Python was unable to find GTK+ without the basepath, but I have tried so many things that I can not know for sure if that was the reason why it finally worked.
Here is a description of how to set the system variable under Windows .
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.