I am using Python3 on an Ubuntu 12.04 system, and I am writing some small apps to teach myself about using cairo from within Python. In idle3 I find the following:
>>> import glib
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import glib
ImportError: No module named glib
I have used Gtk and cairo on the same setup, and python3-gi and python3-gi-cairo are both installed, and in other respects seem to be working fine. It seems there is something else that is missing, but in spite of several web searches I have not unearthed any clues as to what is wrong here.
Can someone please point me in the right direction?
For gobject introspection, which is what python3-gi gives you, the proper incantation is this:
For Cairo, use
cairoinstead ofGLib.In general, at least under Linux, the installed gobject introspection typelibs are installed in
/usr/lib/girepository-1.0(or similar). The name you use to import is derived straightforwardly from the typelib file name.