Can not import modules from gi.repository

10,904

Solution 1

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.

Solution 2

On Wheezy (Debian 7.8) installing python3-gi fixed the problem for me.

Share:
10,904
John Slathon
Author by

John Slathon

Updated on June 04, 2022

Comments

  • John Slathon
    John Slathon almost 2 years

    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!