How To Install Python 2 On Ubuntu 22.04 LTS Jammy Linux

0

Get the easy steps to install Python2 or 2.7 on Ubuntu 22.04 LTS Jammy JellyFish using the command terminal to run old apps 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 for 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 widely used in science. Another important application area is the research and programming of applications in the field of artificial intelligence (AI) and machine learning. For example, TensorFlow.

Advantages of Python Programming Language

Easy to understand syntax
Clear structure and a small number of keywords
No variable declaration is needed
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’s capabilities and scalability
Suitable for complex tasks and almost all application problems
Broad community support

Steps to Install Python 2 on Ubuntu 22.04 LTS Linux

The steps given here can be used for previous Ubuntu versions such as 18.04/20.04, including Debian, Linux Mint, Elementary OS, PO_OS, etc.

1. Perform a system update

It is necessary to perform the system update on Linux if you haven’t done so 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, Python 2.7 can be installed using Ubuntu’s default system repository. Here is the command to follow.

sudo apt install python2

3. Check version

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

python2 --version

Check version

4. Set Python2 as default on Ubuntu 22.04

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

Check which versions of Python are available on your systems:

ls /usr/bin/python*

list python versions

To find out whether a version is configured as a python alternative or not. For this race:

sudo update-alternatives --list python

If the output is:

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

Then that means no alternatives have been configured, so let’s do some.

Here we set up two versions as alternatives, later we can choose between them to set one as the default system.

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

Upgrade to Python version 2

sudo update-alternatives --config python

Upgrade 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 default. For examplehere the Python2 is at number 1so we type this and Walk in key.

Set python alternative 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 Python 2 from Ubuntu 22.04, if it is not needed, the command will be:

First Adjust default version to Python 3 using:

sudo update-alternatives --config python

After that remove version 2 from your system:

sudo apt autoremove python2 --purge

Other Items:

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…

Share.

About Author

Comments are closed.