
Python 2 reached end of life on January 1, 2020, and is no longer officially maintained. Despite its deprecation, some legacy applications and scripts still depend on it. While not recommended for new development, you can install Python 2 on Ubuntu 22.04 using packages available in the official universe repository.
This article shows how to install Python 2 on Ubuntu 22.04, set up pip for Python 2, and verify the installation. If you're working on a different platform, consider reviewing our articles on installing Python and Pip on Ubuntu 24.04 and installing Python 2 on FreeBSD 14.0.
Before you begin, you need to:
Python 2 is no longer included in Ubuntu's default installation, but you can still install it from the official universe repository. The following steps ensure your system is properly configured to locate and install older Python versions.
Update the package index.
Install the required tools for managing repositories.
Check the available version of Python 2 in the APT sources.
Output:
Python 2.7.18 is the latest version available for Ubuntu 22.04.
Install Python 2 from the official Ubuntu repository and confirm the installation.
Install Python 2.
Verify the Python version.
Output:
pip for Python 2pip is the standard package manager for Python. It allows you to install and manage packages from the Python Package Index (PyPI). Python 2 does not include pip by default, so you must install it manually.
Download the get-pip.py script for Python 2.7.
Install pip for Python 2.
Verify the installation.
Output:
After installation, test the Python 2 interpreter to confirm it works correctly.
Open the Python 2 shell.
Run a simple print statement.
Output:
Exit the Python shell.
Python 2 is now installed alongside the default Python 3 environment on Ubuntu 22.04. This setup allows you to run legacy applications that require Python 2 while maintaining compatibility with modern tools.
For more details on legacy development, refer to the Python 2.7 documentation.
0 Comments
Be the first to comment and share your perspective with the community.