Python 2.7 ImportError: No module named repository

I'm completely clueless. I uninstalled, and re installed gi and python2.7. Do you guys have any ideas?

~ > /usr/bin/python
Python 2.7.6 (default, Mar 22 2014, 22:59:56) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import gi
>>> import gi.repository
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named repository

Thank you!


You need to install the following package instead:

sudo apt-get install --reinstall python-gi

This package contains the Python 2.x binding generator for libraries that support gobject-introspection, i. e. which ship a gir1.2-- package. With these packages, the libraries can be used from Python.


Type the command in the terminal:

sudo apt-get install python-gobject

I had the same issue using Ubuntu 16.04. My issue was an update of the python package using pip.

My solution was to remove the package with pip and reinstall it with apt-get:

sudo -H pip uninstall gi

sudo apt-get install --reinstall python-gi

I agree with Sylvain Pineau, but just reinstalling python-gi with apt-get was not enough for me.