1
votes

A server (Ubuntu 18.3) that I work on has python 2.7 and 3.6 installed, and I recently had to install 3.8 for a project. Unfortunately this messed up the default versions and I'm having trouble fixing it.

What I'm getting:

$ python2 --version
Python 2.7.17
$ python3 --version
Python 3.8.5
$ python --version
Python 3.6.9

What I want:

$ python2 --version
Python 2.7.17
$ python3 --version
Python 3.6.9
$ python --version
Python 2.7.17

I tried:

$ sudo update-alternatives --config python
There are 2 choices for the alternative python (providing /usr/bin/python).

  Selection    Path                Priority   Status
------------------------------------------------------------
  0            /usr/bin/python3.8   2         auto mode
* 1            /usr/bin/python3.6   1         manual mode
  2            /usr/bin/python3.8   2         manual mode

$ sudo update-alternatives --config python3
update-alternatives: error: no alternatives for python3

I also saw a symlink for python3 in /usr/bin, but it looks correct:

$ /usr/bin/python3 --version
Python 3.6.9

Thank you very much for the help!

1
The update-alternatives command needs configuration, as linuxconfig.org/ubuntu-20-04-python-version-switch-manager describes in Step3 - Juha M

1 Answers

0
votes

Now in Ubuntu 20.04 LTS the default python3 as python can be simply set by this command:

$ sudo apt install python-is-python3
$ python --version
Python 3.8.5