How to Install Python 2 on Ubuntu 22.04 LTS Jammy Linux

Get the easy steps to install Python2 or 2.7 on Ubuntu 22.04 LTS Jammy JellyFish using the command terminal to run old applications that need this version.

Python is an object-oriented programming language that offers clear syntax and easy readability; it is easy to learn and very versatile. The language was released in 1991 and is similar to PERL. Available to use on UNIX, Linux, Windows, and Mac OS.

The programming language is standard equipment in many Linux distributions. Python can also be used on many mobile operating systems. For web servers, WSGI (Web Server Gateway Interface) is a universal interface between the server and Python.

Python is widespread in the scientific environment. Another important area of ​​application is research and the programming of applications in the field of artificial intelligence ( AI ) and machine learning. For example, TensorFlow.

Advantages of the Python programming language

Easy to understand Syntax
Clear Structure and a small number of keywords
No variable declaration is necessary
Extensive standard library available
Less prone to errors
Fewer lines of code compared to many other programming languages
Support for different programming paradigms
Add-ons to extend Python capabilities and Scalability
Suitable for complex tasks and almost all application problems
Large Community support


Steps to install Python 2 on Ubuntu 22.04 LTS Linux

The steps given here can be used for the previous versions of Ubuntu such as 18.04/20.04 including Debian, Linux Mint, elementary OS, PO_OS, and more…

1. Perform a system update

It is necessary to perform the system update on Linux if you have not done this for a while. This not only installs the latest security updates but also refreshes the APT package manager cache.

sudo apt update


2. Install Python 2 on Ubuntu 22.04 LTS

Even though Python 3 is the default version of Ubuntu 22.04 LTS, yet, Python 2.7 is available to install using the default system repository of Ubuntu. Here is the command to follow.

sudo apt install python2

Install Python 2 on Ubuntu 22.04 LTS


3. Check Version

Once the installation is completed, we can check which version of Python2 is exactly installed on our system.

python2 --version

Check Version


4. Set Python2 as the default version on Ubuntu 22.04

By default Python 3 will be the system-wide default version, however, if you want to switch to Python 2 and set it as the default system follow the below steps:

Check what python versions are available on your systems:

ls /usr/bin/python*

list python versions

To know whether any version is configured as python alternatives or not. For that run:

sudo update-alternatives --list python

If the output is:

“update-alternatives: error: no alternatives for python”

Then it means there are no alternatives that have been configured, hence let’s do some.

Here we are setting up two versions as alternatives, later we will be able to choose between them to set one of them as the system default one.

sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 1
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 2

Switch to Python version 2

sudo update-alternatives --config python

Switch to Python version 2

This time you will see several options including Python 2. Enter the Selection number of the Python you want to set as the system’s default one. For example, here the Python2 is at number 1, hence we type that and Enter key.

Set python alterantive in Ubuntu 22.04

When you check the version of Python this time, you will have 2.7.


5. Uninstall or Remove

To completely remove the Python 2 from Ubuntu 22.04, if not needed, the command will be:

First Set default version to Python 3 using:

sudo update-alternatives --config python

After that remove the version 2 from your system:

sudo apt autoremove python2 --purge


Other Articles:

3 Ways to Install Ruby on Ubuntu 22.04 LTS…
How to Install Maven on Ubuntu 22.04 LTS…
Install VirtualBox on Ubuntu 22.04…
Install VMware Workstation Player on Ubuntu 22.04…


1 thought on “How to Install Python 2 on Ubuntu 22.04 LTS Jammy Linux”

  1. I am trying to install Python Windows Organizer (pywo) into xubuntu 22.04. I had it installed in xubuntu 18.04 and find it a very useful program. It was written 2010 so uses python 2. I don’t know if it used python 2.18. It looked for Xlib in /usr/lib/python2.7/dist-packages/. Xlib was in the version of python2.7 in xubuntu 18.04, but not in xubuntu 22.04. Any idea why python2.7 in ver 18.04 would have Xlib, but not python2.7 in ver 22.04. I tried copying dist-packages from ver 18.04 into ver 22.04, but pywo still didn’t work. Any help would be appreciated……..


Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.