How to update Python to the latest version on Ubuntu 16.04

  • You cannot update python versions within the first two digits (As far, as I am concerned)

That is, although, you can update python3.8 from your current version (let's say 3.8.2) into the highest available at repository (let's say 3.8.5) by the standard sudo apt-get update, you cannot update from python3.8 to python3.9, neither from python2.7 into python 3.5: you must install the new version parallel to the first one. In that way, both versions 3.8 and 3.9 would be installed in your Ubuntu.

For instance, in your case, if you do as @Rustam says sudo apt-get install python3.8, you would not update python2.7 to python3.8, but you would have both python versions installed 2.7 and 3.8.

  • Why can we only install parallel versions instead of updating?

The reason was given by @Rinzwind. If we remove another version of python, we could break all software depending on that version, i.e., we may not be able to run it with the new version. The best example is the incompatibility of python2 and python3 software. But I have also experienced problems trying to run python3.5 software with python3.8.

  • Now, which of all python versions uses my Ubuntu?

You can see that by means of the "python links". These are links in the /usr/bin directory. Just go there and run ll | grep python. You will see 3 important links: python python2 and python3 that tell you the versions that your operative system uses.

For example, in my Ubuntu I have

python -> python3
python2 -> python2.7
python3 -> python3.8

Which means, if python is executed without specifying any version, python3 will be the chosen version. If python2 is executed then the chosen version is 2.7. And finally if python3 is executed then the chosen version is 3.8.


PIP is used to install python packages to your python installations. It is not meant for the installation of new python versions. For this you can run:

sudo apt-get install python3.8

This is currently the latest version. You already have python 3.x in Ubuntu. To get its version, run "python3 --version". If you have 3.6.3 for example, you can update it up to 3.6.9, but you can't turn it into 3.7 or 3.8 - this should be a separate installations. Keeping you python environments separate is quite useful - take a look at this guide: Installing packages using pip and virtual environments