I can not import modules from gi.repository. Specifically not Gtk and GObject.
I experienced this error both on Ubuntu 14.04 LTS and after reinstall also on Linux Mint 17.
from gi.repository import Gtk, GObject
Results in the 'unresolved reference' warning for the respective modules. Interestingly enough my Gtk GUI can be compiled and works perfectly fine. Yet, GObject is entirely out of function.
I tried to work around with altering import statements such as:
from gi.repository.Gtk import*
Even hard coding the import path via:
sys.path.append('/usr/lib/python2.7/dist-packages/gi')
None of these approaches have solved this frustrating error so far.
I have not found any concluding help or basic info on this issue, neither anywhere on the web nor in Linux forums or here on stackoverflow. I am not sure whether this problem lies on the Python or the Linux side of things.
Can anybody suggest how to solve this issue? What additional information do I need to provide eventually.
Thanks!
The require_version method ensures the namespace gets loaded with the given version. The gi. repository is the Python module for PyGObject . PyGObject (Python GObject introspection) contains Python bindings and support for GObject, GLib, GTK and other libraries. $ ./version.py 4.6.5.
Open a terminal and enter your virtual environment. Execute sudo zypper install cairo-devel pkg-config python3-devel gcc gobject-introspection-devel to install the build dependencies and GTK. Execute pip3 install pycairo to build and install Pycairo. Execute pip3 install PyGObject to build and install PyGObject.
gi. repository is the Python module for PyGObject (which stands for Python GObject introspection) which holds Python bindings and support for the GTK+ 3 toolkit and for the GNOME apps.
If on a Debian-based system such as Ubuntu, you probably need to install the gir1.2-gtk-3.0
package and other similarly named packages for other libraries. I don't know what the name of the package would be on Mint, but it's probably something similar.
On Wheezy (Debian 7.8) installing python3-gi
fixed the problem for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With