Python 2.7 ImportError: No module named repository
Solution 1
Thank you everyone for your responses.
I had another version of python installed in my /usr/local/bin.
Solution 2
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.
Solution 3
Type the command in the terminal:
sudo apt-get install python-gobject
Solution 4
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.
Related videos on Youtube
Tyler Berezowsky
Updated on September 18, 2022Comments
-
Tyler Berezowsky almost 2 years
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!
-
Sylvain Pineau over 9 yearsThat's weird, did you start your interpreter inside a venv? If yes try with
mkvirtualenv environment --system-site-packages
instead -
Tyler Berezowsky over 9 yearsHey @Sylvain Pineau thanks for help! I don't believe so. I just found that gobject-introspection was missing though! Sadly, I can still not import gi.repository or run software-center.
-
Jay over 9 yearsI would highly recommend the use of virtual environments. This solves any conflicting dependency problems. They are very easy to install, and it basically creates a standalone python environment for each virtualenv. That way, you can use version 1 of package X in Project Y, but use version 2 of package X in Project Z, without running into dependency he'll.
-
Tyler Berezowsky over 9 yearsI mainly use Python through the anaconda distribution to avoid Matlab. I started dappling with gui interfaces through GTK when I some how broke everything . Would a virtual environment work for that to avoid messing with my system's install of python? i.e. be able to access ubuntu's notifications, and panel?
-
Jay over 9 yearsMost definitely.