Categories: Ubuntu

How to Install Python 2 on Ubuntu

According to the official reports from developers of Python, Python 2 has been completely removed from Ubuntu 20.4, and its default version is not installed on Ubuntu. Sometimes, users require old programs, and they find a way to install them. Ubuntu users can configure and install Python 2 on this operating system. This article will see how you can easily install Python 2 and use it as the default Python interpreter.

To install Python 2 in Ubuntu, first, update the system by the following command:

sudo
Sponsored
apt update

Now, execute the following command for installing Python 2 from the terminal:

sudo apt install python2


It will take your permission for confirmation. For this, press the Y and then Enter button to resume the download.

Once the above command is executed, you can check your system’s currently installed Python version. To check its current version, execute the command written below in the terminal.

python2 -V

Similarly, you can also check the version of Python 3.

python3 – V

To check which version of Python is available for the system, run the following command in the terminal.

ls /usr/bin/python*


If you want to verify python configure options, then execute the below command:

Sponsored
sudo update-alternatives –list python

Note: Once Python 2 is installed, you can also switch from Python 3 to Python 2 in Ubuntu 20.4 as per your requirements.

Here, for example, we will set two options, Python 2 and Python 3. As we saw above, we have the 2.7 version of Python 2, and the 3.8 version of python 3 is available.

sudo update-alternatives –install /usr/bin/python python /usr/bin/python3 2

sudo update-alternatives –install /usr/bin/python python /usr/bin/python2 1


You can also check the option selected with the above command, so use the following command for it.

sudo update-alternatives –list python


You can select an alternate Python version by executing.

sudo update-alternatives –config python


According to the above example, choose 1 to select Python 2 according to our requirements.

Conclusion

This article shows an installation of Python 2 in Ubuntu 20.4. After installing Python 2, you can also check its current version of our system. The article also explains how to switch between Python versions. We hope this article proves beneficial to you and the information given by us will be helpful to you.

Ubuntu Server Admin

Recent Posts

Canonical Releases Ubuntu 25.04 Plucky Puffin

The latest interim release of Ubuntu introduces “devpacks” for popular frameworks like Spring, along with…

2 days ago

Ubuntu 25.04 (Plucky Puffin) Released

Ubuntu 25.04, codenamed “Plucky Puffin”, is here. This release continues Ubuntu’s proud tradition of integrating…

3 days ago

Extended Security Maintenance for Ubuntu 20.04 (Focal Fossa) begins May 29, 2025

Ubuntu released its 20.04 (Focal Fossa) release 5 years ago, on March 23, 2020. As…

3 days ago

Ubuntu 20.04 LTS End Of Life – activate ESM to keep your fleet of devices secure and operational

Focal Fossa will reach the End of Standard Support in May 2025, also known as…

4 days ago

Ubuntu MATE 25.04 Release Notes

Ubuntu MATE 25.04 is ready to soar! 🪽 Celebrating our 10th anniversary as an official…

5 days ago

Ubuntu Weekly Newsletter Issue 887

Welcome to the Ubuntu Weekly Newsletter, Issue 887 for the week of April 6 –…

6 days ago