Tutorials  /  Python

Install Python 2 on Ubuntu 22.04 with pip Setup

Ccentron Redaktion · August 2025 ·4 min read ·Python, Tutorial

Python 2 reached its official end of life on January 1, 2020, and is no longer actively maintained. Although deprecated, certain older applications and scripts still rely on it. While it is not advised for new projects, Python 2 can still be installed on Ubuntu 22.04 using packages from the official universe repository.

This guide explains how to install Python 2 on Ubuntu 22.04, configure pip for Python 2, and confirm the installation. If you are using another operating system, you may want to review our guides for installing Python and Pip on Ubuntu 24.04 or setting up Python 2 on FreeBSD 14.0.

Prerequisites

  • Access to an Ubuntu 22.04 system with a non-root user who has sudo privileges.
VM

Matching infrastructure at centron

Scripts and services eventually need an environment that keeps running: ccloud³ VMs from €3.12 per month, billed by the hour. Rent a cloud server →

Enable the Python Repository

Python 2 is not part of Ubuntu’s default setup, but it can still be obtained from the official universe repository. The following steps prepare your system to locate and install older Python releases.

Update the package index

Console
$ sudo apt update

Install repository management tools

Console
$ sudo apt install -y software-properties-common

Check the available Python 2 version

Console
$ apt policy python2

Sample output:

YAML
python2:
  Installed: (none)
  Candidate: 2.7.18-3
  Version table:
     2.7.18-3 500
        500 http://archive.ubuntu.com/ubuntu jammy/universe amd64 Packages

For Ubuntu 22.04, Python 2.7.18 is the most recent version available.

Install Python 2

Install Python 2 from the official Ubuntu repository and verify the installation.

Install Python 2

Console
$ sudo apt install -y python2

Check the Python version

Console
$ python2 --version

Sample output:

Code
Python 2.7.18

Install pip for Python 2

pip is Python’s standard package manager, allowing installation and management of packages from the Python Package Index (PyPI). Since Python 2 does not come with pip by default, it must be installed manually.

Download the get-pip.py script

Console
$ curl https://bootstrap.pypa.io/pip/2.7/get-pip.py --output get-pip.py

Install pip for Python 2

Console
$ sudo python2.7 get-pip.py

Verify pip installation

Console
$ pip2.7 --version

Sample output:

Console
pip 20.3.4 from /usr/local/lib/python2.7/dist-packages/pip (python 2.7)

Test and Use Python 2

After installation, test the Python 2 interpreter to ensure it runs properly.

Start the Python 2 shell

Console
$ python2

Run a simple print statement

Code
>>> print('Hello, World!')

Sample output:

Code
Hello, World!

Exit the Python shell

Code
>>> quit()

Conclusion

Python 2 is now installed alongside the default Python 3 environment on Ubuntu 22.04. This configuration lets you maintain legacy applications that depend on Python 2 while still using modern Python 3 tools.

For more detailed information on maintaining Python 2 projects, consult the official Python 2.7 documentation.

Jetzt 200 € Guthaben sichern

Testen Sie Ihr Setup auf ccloud³

Registrieren Sie sich in der ccloud³ und erhalten Sie 200 € Startguthaben für Ihr Projekt – z. B. für eine PostgreSQL-VM mit automatischen Backups.

centron Redaktion Technische Redaktion

Das Redaktionsteam von centron schreibt Anleitungen aus dem Betriebsalltag: getestet auf unserer eigenen Plattform, betrieben im Rechenzentrum in Hallstadt bei Bamberg.

Kategorie Python
Teilen
Noch offene Fragen?

Unser Team hilft Ihnen bei Ihrem konkreten Setup weiter – von Menschen, die die Plattform selbst betreiben.

War dieses Tutorial hilfreich?

Ihre Antwort wird anonym gespeichert und hilft uns, die Tutorials zu verbessern.

Kommentare

Noch keine Kommentare – stellen Sie die erste Frage zu diesem Tutorial.

Zum Kommentieren anmelden

Kommentare stehen centron-Kunden offen. Melden Sie sich in Ihrem Konto an, um eine Frage zu diesem Tutorial zu stellen.

Weiterlesen

Das könnte Sie auch interessieren

Jetzt kostenlos anfangen

Melden Sie sich an und erhalten Sie in den ersten 60 Tagen ein Guthaben von 200 € bei centron.

Dieses Werbeangebot gilt nur für neue Konten. Angebot ausschließlich für Gewerbetreibende.

Jetzt loslegen Sales kontaktieren