6

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!

2
  • does this help askubuntu.com/questions/80448/…
    – mchid
    Mar 10, 2015 at 4:26
  • 1
    Hey! Thanks for the comment! Checked that post. Reconfigured python2.7. Reinstalled python-gobject and python-gobject-2. /usr/lib/python2.7/dist-packages is in path. gi exists. For some reason gi.repository doesn't. Not sure what that is. @mchid Mar 10, 2015 at 4:38

4 Answers 4

4

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.

3
  • I already removed and re installed python-gi Mar 10, 2015 at 12:45
  • That's weird, did you start your interpreter inside a venv? If yes try with mkvirtualenv environment --system-site-packages instead Mar 10, 2015 at 12:50
  • Hey @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. Mar 10, 2015 at 13:14
2

Type the command in the terminal:

sudo apt-get install python-gobject
2

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.

1

Thank you everyone for your responses.

I had another version of python installed in my /usr/local/bin.

3
  • I 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.
    – Gx1sptDTDa
    Mar 15, 2015 at 15:36
  • I 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? Mar 15, 2015 at 18:55
  • Most definitely.
    – Gx1sptDTDa
    Mar 15, 2015 at 20:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .