---
title: How to Install Python 2 on Ubuntu 22.04
url: https://docs.vultr.com/how-to-install-python-2-on-ubuntu-22-04
description: Learn how to install Python 2 on Ubuntu 22.04 with our step-by-step guide. Discover the commands and procedures needed to get this legacy version running on your system.
publish_date: 2025-07-02T16:01:08.962472Z
last_updated: 2025-07-02T16:01:08.962472Z
author: Hitesh Jethva
header_image: https://docs.vultr.com/public/doc-assets/2248/c89cd084-4797-406a-b363-ccb0d3a8c00d.png
---

> Index of every Vultr Docs page in markdown: https://docs.vultr.com/llms.txt

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](https://docs.vultr.com/how-to-install-python-and-pip-on-ubuntu-24-04) and [installing Python 2 on FreeBSD 14.0](https://docs.vultr.com/how-to-install-python-2-on-freebsd-14).

## Prerequisites

Before you begin, you need to:

* Have access to an [Ubuntu 22.04 instance](https://www.vultr.com/servers/ubuntu) as a non-root sudo user.

## Add the Python Repository

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.

1. Update the package index.

    ```console
    $ sudo apt update
    ```

1. Install the required tools for managing repositories.

    ```console
    $ sudo apt install -y software-properties-common
    ```

1. Check the available version of Python 2 in the `APT` sources.

    ```console
    $ apt policy python2
    ```

    Output:

    ```
    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
    ```

    Python 2.7.18 is the latest version available for Ubuntu 22.04.

## Install Python 2

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

1. Install Python 2.

    ```console
    $ sudo apt install -y python2
    ```

1. Verify the Python version.

    ```console
    $ python2 --version
    ```

    Output:

    ```
    Python 2.7.18
    ```

## Install `pip` for Python 2

`pip` 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.

1. Download the `get-pip.py` script for Python 2.7.

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

1. Install `pip` for Python 2.

    ```console
    $ sudo python2.7 get-pip.py
    ```

1. Verify the installation.

    ```console
    $ pip2.7 --version
    ```

    Output:

    ```
    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 confirm it works correctly.

1. Open the Python 2 shell.

    ```console
    $ python2
    ```

1. Run a simple print statement.

    ```python
    >>> print('Hello, World!')
    ```

    Output:

    ```
    Hello, World!
    ```

1. Exit the Python shell.

    ```python
    >>> quit()
    ```

## Conclusion

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](https://docs.python.org/2.7/).
