Run these commands to ensure your repositories are up to date before installing

Copysudo apt update
sudo apt upgrade
sudo apt install python2.7

Then to install pip for python 2:

Copysudo apt install python-pip
Answer from Spiff on Stack Overflow
🌐
GitHub
github.com › ctch3ng › Installing-Python-2.7-and-pip-on-Ubuntu-24.04-Noble-LTS
GitHub - ctch3ng/Installing-Python-2.7-and-pip-on-Ubuntu-24.04-Noble-LTS · GitHub
./configure --prefix=/usr/local/python2.7 make sudo make install · Option 2: Optimized Build (For potential performance gains) The --enable-optimizations flag enables Profile-Guided Optimization (PGO), which can result in a slightly faster ...
Starred by 31 users
Forked by 6 users
🌐
TecAdmin
tecadmin.net › install-python-2-7-on-ubuntu-and-linuxmint
How to Install Python 2.7 on Ubuntu, Debian & Linux Mint
April 26, 2025 - Learn to install Python 2.7 on Ubuntu, Debian & Linux Mint. Our guide covers the full process, ensuring a secure setup for legacy applications.
Discussions

apt - How to install python2.7-dev package on vanilla debian 12? - Unix & Linux Stack Exchange
Later on, if your project compiles ... ~/Downloads/Python-2.7.18/build/lib.linux-x86_64-2.7 to sys.path. (I'm on Linux Mint 22.2 but the same steps should apply). ... Find the answer to your question by asking. Ask question ... See similar questions with these tags. ... You don’t understand DNS like you think you... Dispatches from O'Reilly: From capabilities to... ... 1 What issues might there be with both an 'apt-get install ...' and a ... More on unix.stackexchange.com
🌐 unix.stackexchange.com
February 5, 2024
Need to install python 2. How do I accomplish this?
If you're in need of multiple different languages being installed, I've very much enjoyed using the tool "mise". It's a language env manager. If you install mise, you can use it to manage your different language installs. mise use python@2.x.y.z This would install and use Python with that version globally. More on reddit.com
🌐 r/linuxmint
18
0
March 23, 2025
How do I install python 2.7
You don't. Nobody ships it anymore. It's unmaintained and is a security risk. Find an alternative in Python 3 or another language. There are libraries and tools to convert to Python 3, use those. Become a better Python programmer and do it yourself. Otherwise you can install a VM of an old Linux release like Ubuntu 18.04 and try it there. Keep it off the internet and away from your personal files. More on reddit.com
🌐 r/linuxquestions
21
0
November 23, 2023
How to install python 2.7.17 ?
You'll need to compile from source. Either by downloading that version yourself or using something like pyenv. Why do you need Python 2 and that version specifically? There were basically no changes between 2.7.17 and 2.7.18, besides some minor fixes, security fixes and the EOL message. More on reddit.com
🌐 r/linuxquestions
5
1
January 22, 2022
🌐
LinuxShout
linux.how2shout.com › home › how to install python 2.7 on ubuntu 20.04 lts
How to install Python 2.7 on Ubuntu 20.04 LTS - LinuxShout
June 18, 2024 - sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 1 sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 2
🌐
The Hitchhiker's Guide to Python
docs.python-guide.org › starting › install › linux
Installing Python 2 on Linux — The Hitchhiker's Guide to Python
You can install the python2 package with your distribution package manager: ... You do not need to install or configure anything else to use Python. Having said that, I would strongly recommend that you install the tools and libraries described ...
Find elsewhere
🌐
TecAdmin
tecadmin.net › install-python-2-7-on-centos-rhel
How to Install Python 2.7 on CentOS/RHEL 9/8 and Fedora
April 26, 2025 - Learn to install Python 2.7 on CentOS, RHEL & Fedora. Our guide covers the full process, ensuring a secure setup for legacy applications.
Top answer
1 of 3
5

You can still install Python 2.7 from Debian 11. Mixing releases is typically decried as a bad idea, but that is mostly in the context of adding a newer release; adding an older (still-supported) release is much less error-prone, as long as you keep an eye on any packages apt wants to remove.

Add a file, /etc/apt/sources.list.d/bullseye.list, containing

deb http://deb.debian.org/debian bullseye main
deb http://deb.debian.org/debian bullseye-updates main
deb http://security.debian.org bullseye-security main

Run sudo apt update, and you will be able to install python2.7-dev.

As you are probably aware, maintaining Python 2-based projects is becoming increasingly difficult, and the above won’t be a viable approach once Debian 11 is no longer supported (some would argue it already isn’t viable).

2 of 3
1

The PPA Approach

While Stephen's answer is certainly viable until Bullseye is no longer supported. I believe this approach will survive until the various python versions are removed from the PPA. Adding this PPA or Personal Package Archive, or any for that matter is relatively easy.

The PPA Specifically for Python

The Dead Snakes Personal Package Archive contains packaged versions of Python all the way back to 2.3. Add it with: sudo add-apt-repository ppa:deadsnakes/ppa

Note that these are made to work with Ubuntu, and since that's a Debian derivative:

The packages may also work on other versions of Ubuntu or Debian, but that is not tested or supported.

See also: Install newer & older versions of python on debian?. Read Gilles' answer from 8 years ago that's still quite valid.

🌐
LinuxConfig
linuxconfig.org › home › install python 2 on ubuntu 20.04 focal fossa linux
Install Python 2 on Ubuntu 20.04 Focal Fossa Linux
June 17, 2022 - This tutorial will show how to install Python2 for Ubuntu 20.04 Focal Fossa Linux. Python 2 has not been the default installed version on Ubuntu for a few years, but it’s still possible to install Python2 and to install Python 2.7 on Ubuntu.
🌐
Python
python.org › download › releases › 2.7
Python 2.7.0 Release | Python.org
Python 2.7 is scheduled to be the last major version in the 2.x series before it moves into an extended maintenance period. This release contains many of the features that were first released in Python 3.1. Improvements in this release include: ... Change log for this release. ... Report bugs at http://bugs.python.org. Help fund Python and its community. This is a production release. Please report any bugs you encounter. ... Mac Installer disk image (2.7.0) for OS X 10.5 and later (sig).
🌐
Reddit
reddit.com › r/linuxquestions › how do i install python 2.7
r/linuxquestions on Reddit: How do I install python 2.7
November 23, 2023 - Otherwise you can install a VM of an old Linux release like Ubuntu 18.04 and try it there. Keep it off the internet and away from your personal files. ... Yes, 18.04 is the last Ubuntu with Python 2.
🌐
Medium
medium.com › @kallagoutham33 › how-to-install-python-2-on-ubuntu-24-04-12c0819278ba
How to install Python 2 on Ubuntu 24.04 | by Goutham Kalla | Medium
October 6, 2025 - sudo apt update sudo apt install build-essential checkinstall sudo apt install libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev ... tar -xvf Python-2.7.18.tgz cd Python-2.7.18 ./configure --enable-optimizations ...
🌐
nixCraft
cyberciti.biz › nixcraft › howto › python › how to install python on linux 2.x/3.x latest version
How To Install Python On Linux 2.x/3.x latest version - nixCraft
March 28, 2023 - For example: $ sudo apt update ... Run the following apt command/apt-get command to install python version 2.x: $ sudo apt-get install python2.7 Type the following command to install python version 3.8 or 3.9: $ sudo apt-get ...
🌐
Greenwebpage
greenwebpage.com › home › blog › how to install python 2 on ubuntu 24.04: 3 quick methods
How to Install Python 2 on Ubuntu 24.04: 3 Quick Methods
April 3, 2025 - Now, set up a virtual environment ... Python will use Python 2 instead of Python 3: ... Inside the virtual environment, you can install Python 2 packages using pip....
🌐
Linux Hint
linuxhint.com › install-python-2-ubuntu
How to Install Python 2 on Ubuntu – Linux Hint
This article will see how you can easily install Python 2 and use it as the default Python interpreter.
🌐
GitHub
gist.github.com › lukaslundgren › 2659457
How to install python 2.7 on debian · GitHub
I would definitely install it in a different directory, so you don't overwrite the distribution's package contents (You will start seeing lots of errors!). See here for ideas on installing multiple versions: http://www.extellisys.com/articles/python-on-debian-wheezy · However, this was useful to me for setting up 2.7.8, which is the current version available from Python.org.