Gnome-terminal does not start due to an error in the GI-related python script

advertisements

When I run gnome-terminal, I get the following error:

Traceback (most recent call last):
  File "/usr/bin/gnome-terminal", line 9, in <module>
    from gi.repository import GLib, Gio
  File "/usr/local/lib/python3.4/dist-packages/gi/__init__.py", line 39
    print url

This looks odd to me, because the script is located in a python 3.4 installation but is calling print as if it was a python2 script (which is why the error occurs).

I tried to reinstall the package gi with pip3, but it keeps installing this version that looks like a python2 script.

My gnome-terminal points to /usr/bin/gnome-terminal, which is a python script that starts with #!/usr/bin/python3.

The lines with that particular error in init.py are:

if __name__ == '__main__':
         try:
                 url = save_file()
                 print url
         except GistError as e:
                 print e.value

This suggests a quick fix: putting parenthesis in those two print lines.

  File "/usr/bin/gnome-terminal", line 9, in <module>
    from gi.repository import GLib, Gio
ImportError: No module named 'gi.repository'

Which is strange.

This must be running on /usr/bin/python3, because that's what on the shebang on /usr/bin/gnome-terminal.

python3 on the /usr/bin is actually a link to python3.4, which is a binary file.

I then run pip3 install gi and I get the following output, which tells me that actually gi is installed.

Requirement already satisfied (use --upgrade to upgrade): gi in /usr/local/lib/python3.4/dist-packages
Requirement already satisfied (use --upgrade to upgrade): requests in /usr/lib/python3/dist-packages (from gi)

And right now I am out of ideas.

This started after I tried to install a Pumubuntu from https://github.com/Pumubuntu/Pumubuntu.

In the main script file it says:

import sys
if len(sys.argv) == 1:
    print('Importing Python modules. If one is missing get it with:\n'
          '  "sudo apt-get install python-..." or\n'
          '  "sudo apt-get install girX.Y-..." for gi.repository imports.')

So I thought I had to enter those commands. And that must have broken my gir installation (gir).

Can anybody help me?


This is an old question but this being the first google hit, it should be answered.

The error is caused by installing gi package on python3.
It is a package for GIST Github commandline for python2. It is not related to gnome object or gnome introspection. Visit it here: python gi on package index

It causes naming conflicts with gi.repository, rather than looking for gir in your python dist-packages, your system __init__ the gi package. And hence the error shows

ImportError: No module named 'gi.repository'

Uninstalling that package will resolve the error. Also if you are looking for a gister, try defunkt gist