0

I installed Python3 yesterday, but I have the feeling I didn't do a good job:

:~$ gnome-terminal
Traceback (most recent call last):
  File "/usr/bin/gnome-terminal", line 9, in <module>
    from gi.repository import GLib, Gio
  File "/usr/lib/python3/dist-packages/gi/__init__.py", line 42, in <module>
    from . import _gi
ImportError: cannot import name '_gi' from 'gi' (/usr/lib/python3/dist-packages/gi/__init__.py)

I get the same error when trying to remove the PPA (in 404) with:

 add-apt-repository --remove ppa:/jonathonf/python-3.7

And yet, Python runs smoothly. This might be helpful too:

~$ python --version
Python 2.7.15rc1
~$ python3 --version
Python 3.7.0b3
~$ type -a python3; file $(type -aP python3)
python3 is /usr/bin/python3
/usr/bin/python3: symbolic link to /etc/alternatives/python3
~$ python3.5 --version # Expected, I installed 3.6 and 3.7 - I only added the 3.5 link as a following desperate attempt
bash: /usr/lib/command-not-found: /usr/bin/python3: bad interpreter: No such file or directory
~$ python3.6 --version
Python 3.6.5
~$ python3.7 --version
Python 3.7.0b3

Running Ubuntu 18.04

The error persists after re-installing gnome-terminal. I've found this post that doesn't have an answer, but they suggest to re-install Ubuntu, like, I hope they're joking (:

ecoologic
  • 1,050

1 Answers1

1

Step 3 in the instructions you followed is wrong. Different versions of Python 3 are not alternatives for Ubuntu.

Thankfully, it should be easy to fix. Just use similar commands to the ones in the update at the bottom of the instructions, but with the correct Python version for your Ubuntu version, i.e. Python 3.5 for Ubuntu 18.04:

sudo rm /usr/bin/python3
sudo ln -s python3.6 /usr/bin/python3
wjandrea
  • 14,504