We knew Ubuntu 20.04 will set python 3 as default python, but after upgrade from 18.04 to 20.04, I found my default python version is 2.7.18rc1 not python3:

my system version and python version

  • 7
    This is a known issue. See: linuxuprising.com/2020/04/… Further more, /usr/bin/python is not present on new Ubuntu 20.04 installs (for upgraded systems, /usr/bin/python continues to point to python2). If you need /usr/bin/python to point to python3, install the python-is-python3 package. – Stephen Boston Apr 29 '20 at 16:07
  • 4
    There is currently no plan to make python point to python3. That would break a lot of legacy homemade python2 scripts still floating around on folks' systems, and would confuse a lot of folks needlessly. – user535733 Apr 29 '20 at 16:34
  • Related: askubuntu.com/questions/1165360 – Kulfy Apr 29 '20 at 20:27
  • @karel the duplicate question does say "But I still have it. Why is that?" and then runs the python command to show what they're talking about. Look beyond the title into the actual question. $ python Python 2.7.18rc1 – muru May 4 '20 at 8:11
  • In this question the OP wants to know what to do with the python command either to start the system default Python 3 interpreter or how to start the system default Python 3 interpreter with a different command (a command different from python) in order to be able to use Python 2 alongside Python 3. Let's assume that the OP in this question already knows that Python 2 is still supported in 20.04 from his own screenshot. – karel May 4 '20 at 8:22

Running the python command in the terminal starts the Python 2 interpreter if Python 2 is installed, as it is in your Ubuntu 20.04. In Ubuntu 20.04 you can also start Python 3 which is preinstalled with the python command by installing the python-is-python3 package.

sudo apt install python-is-python3

You can also start the Python 3 interpreter from the terminal the usual way by running python3

  • root@debian:~# apt install python-is-python3 Reading package lists... Done Building dependency tree Reading state information... Done E: Unable to locate package python-is-python3 – James Bowery Dec 14 '20 at 21:51
  • Results of apt policy python-is-python3 : python-is-python3: Installed: (none) Candidate: 3.8.2-4 Version table: 3.8.2-4 500 500 http://il.archive.ubuntu.com/ubuntu focal/main amd64 Packages – karel Dec 15 '20 at 4:27

Apart from a solution with installing python-is-python3 (mentioned in comment by Stephan Boston), there's one more using update-alternatives or using GUI galternatives, which would work not only with python, but any tool and any number of its versions.

Let's start at the very beginning. I have newly installed Ubuntu 20.04 and in /usr/bin don't even have sole python, but only python3 and python2. You type:

# update-alternatives --install /usr/bin/python python /usr/bin/python3 10
# update-alternatives --install /usr/bin/python python /usr/bin/python2 9
# update-alternatives --config python

After typing the last command you would be asked to choose the prefered version manually or leave the selection in auto mode, where in our example python3 has higher priority 10 than 9 of python2, so python3 would be default.

 Selection    Path               Priority   Status
* 0            /usr/bin/python3   10        auto mode
  1            /usr/bin/python2   9         manual mode
  2            /usr/bin/python3   10        manual mode

If I've typped 1:

$ python --version
Python 2.7.18rc1

I've changed my mind and in update-alternatives --config python selected 0 for auto (bidding for the highest priority):

$ python --version
Python 3.8.2

Not the answer you're looking for? Browse other questions tagged or ask your own question.