terminal won't launch after install python 3.5
After I installed Python 3.5 and ran the commands below, my terminal and many other programs won't launch any more.
cd /usr/bin
sudo rm python3
sudo ln -s python3.5 python3
How can I restore the default Python version again to fix these problems?
Step 1: Opening a terminal
You said that you could not open a terminal any more. That is because the standard terminal emulator in Ubuntu is gnome-terminal
, which can't run without a working python3
, as that's one of its dependencies:
$ apt-cache depends gnome-terminal | grep python
Depends: python3
Depends: python3-gi
However, there are alternatives:
-
Use another terminal emulator:
You can simply use another terminal emulator than
gnome-terminal
, for examplexterm
which should also be installed by default. Search it in the dash's application lens (Super+A) or just runxterm
from the HUD (Alt+F2).A new terminal window will open from where you can undo your previous operations. It's (in my opinion) less comfortable than the default
gnome-terminal
, but surely does its job without depending on any Python components:$ LANG=C apt-cache depends xterm | grep python $
-
Use a TTY terminal:
Instead of using a terminal emulator (terminal window in a graphical environment) you can also temporarily switch to a real terminal (console only, no graphics) by pressing Ctrl+Alt+F1 (or any F [n] key with n in the range of 1 to 6).
You switch back to the graphical surface (usually TTY7) with Ctrl+Alt+F7 (or another F [n] key with n in the range of 7 to 12, depending on your user sessions).
In the TTY, you will have to log in by typing your username and password again first. Then it works like a normal terminal. Don't forget to log out of the TTY session again with Ctrl+D or the command
exit
when you're done.
Step 2: Restoring the original python3
Whatever method you used to get a terminal, the following reparation step is the same.
You have to restore the original /usr/bin/python3
file, which was actually a symlink to python3.4
(or absolute path /usr/bin/python3.4
). This is done by the following simple command:
sudo ln -sf /usr/bin/python3.4 /usr/bin/python3
You can't replace Python 3.4 with 3.5 on Ubuntu, because many (system) applications rely on it. This includes the symlink python3
.
Given that you have not removed python3.4
, restore the original symlink with
cd /usr/bin
sudo rm python3
sudo ln -s python3.4 python3
Call Python3.5 directly with python3.5