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!

Tyler Berezowsky
  • 185
  • 2
  • 3
  • 10
  • does this help http://askubuntu.com/questions/80448/what-would-cause-the-gi-module-to-be-missing-from-python – mchid Mar 10 '15 at 04: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 – Tyler Berezowsky Mar 10 '15 at 04:38

4 Answers4

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.

Sylvain Pineau
  • 61,564
  • 18
  • 149
  • 183
2

Type the command in the terminal:

sudo apt-get install python-gobject
Hizqeel
  • 1,887
  • 28
  • 22
  • 24
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.

M. Becerra
  • 3,339
  • 5
  • 22
  • 39
kirby_33
  • 146
  • 1
  • 2
1

Thank you everyone for your responses.

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

Tyler Berezowsky
  • 185
  • 2
  • 3
  • 10
  • 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 '15 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? – Tyler Berezowsky Mar 15 '15 at 18:55
  • Most definitely. – Gx1sptDTDa Mar 15 '15 at 20:32