Install Python v3.9.0 in Ubuntu 20.04 LTS

In this article, we would discuss how to install Python v3.9.0 in Ubuntu 20.04 LTS release. Python first appeared in the early 1990s. Guido van Rossum created it. Python Software Foundation, a non-profit corporation, oversees its development now.

At the time of writing, Python’s latest stable release is 3.9.0. As of now, the default Python version in Ubuntu 20.04 LTS is 3.8.5.

Furthermore, we can either keep the default Python version installed alongside latest stable release or replace it. We will discuss both the scenarios.

To verify for the Python version (if already installed), issue the following in terminal –

python3 -V

It may return with –

Python 3.8.5

Note: Following operations would require you to have superuser privileges. In case you don’t have one then we advise you to contact your System Administrator for assistance.

Install Python 3.9.0 in Ubuntu 20.04 LTS

Firstly, we have to download the relevant package from the official website of Python. Once you land on the homepage of the official website, look for Downloads drop-down menu at the top. Then, click All releases. Thereafter, scroll down the page and find different Python release versions. Click on Download web address against Python 3.9.0. It will open a new web page. Look for Gzipped source tarball web address to download the required package.

The downloaded package – Python-3.9.0.tgz, is approximately 26MBs in size.

Now, use tar command-line utility to extract the tgz package –

cd /path/to/downloaded/package
tar -xvf Python-3.9.0.tgz

It will create Python-3.9.0/ in the current directory. Next, install few packages from the standard Ubuntu repository –

sudo apt install build-essential zlib1g-dev libdb5.3-dev libncursesw5-dev libsqlite3-dev
sudo apt install libncurses5-dev libffi-dev tk-dev libreadline-dev libssl-dev
sudo apt install liblzma-dev libbz2-dev libexpat1-dev libgdbm-dev

Thereafter, issue the following commands to configure the package –

./configure
make
make test

Finally, as discussed earlier we have got two scenarios –

  1. If we would want to replace the existing Python v3.8.5 and install v3.9.0 –
    sudo make install

    To verify the Python version installed –

    python3 -V
  2. Otherwise, we can also install Python v3.9.0 alongside Python v3.8.5 –
    sudo make altinstall

    To verify different Python versions installed –

    python3 -V
    python3.9 -V

In conclusion, we have discussed how to install Python v3.9.0 in Ubuntu 20.04 LTS release.

Additional Info –

Since we have installed Python v3.9.0 through a binary installer. Therefore, we don’t have to install PIP separately. It comes bundled with the Python binary installer. We can verify the installation through –

pip3.9 -V

Similar Posts