It is still possible, firstly open /etc/apt/sources.list and add this new line, which adds Debian 9 software to apt-get sources: deb http://archive.debian.org/debian/ stretch contrib main non-free then in bash type the following command: sudo apt-get update sudo apt-get install python2.7 Now you should be able to use python2.7 in Debian12. Don't forget to remove that new line in /etc/apt/sources.list,otherwise it may affect your future apt-get Answer from forsakensilver on reddit.com
It is still possible, firstly open /etc/apt/sources.list and add this new line, which adds Debian 9 software to apt-get sources: deb http://archive.debian.org/debian/ stretch contrib main non-free then in bash type the following command: sudo apt-get update sudo apt-get install python2.7 Now you should be able to use python2.7 in Debian12. Don't forget to remove that new line in /etc/apt/sources.list,otherwise it may affect your future apt-get Answer from forsakensilver on reddit.com
🌐
Vultr
docs.vultr.com › how-to-install-python-2-on-debian-12
How to Install Python 2 on Debian 12 Complete Guide | Vultr Docs
July 2, 2025 - Debian 12 does not include Python 2 in its default repositories. To install it, compile Python 2.7.18 from source.
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.

🌐
Debian
wiki.debian.org › Python
Python - Debian Wiki
May 20, 2026 - Converting your package to dh_python2 ... dependencies. As root, run: "aptitude build-dep python3" Pick your version and download the "Gzipped source tarball" of the version of your choice from Python download page....
🌐
Centron
centron.de › startseite › install python 2.7.18 & pip on debian 12 from source
Install Python 2.7.18 & PIP on Debian 12 from Source
August 18, 2025 - Learn how to install Python 2.7.18 and PIP on Debian 12 from source, verify the setup, and run scripts for legacy application support.
🌐
Fadedbee
fadedbee.com › 2024 › 01 › 18 › installing-python2-on-debian-12-bookworm
Installing Python 2.7 on Debian 12 (Bookworm) · 0xFADEDBEE
January 18, 2024 - Distributor ID: Debian Description: Debian GNU/Linux 12 (bookworm) Release: 12 Codename: bookworm fadedbee@box:~$ python2.7 bash: python2.7: command not found fadedbee@box:~$ cd ~/Downloads/ fadedbee@box:~/Downloads$ ls *.deb code_1.85.0-1701902998_amd64.deb libssl1.1_1.1.1w-0+deb11u1_amd64.deb libffi7_3.3-6_amd64.deb python2.7_2.7.18-8+deb11u1_amd64.deb libpython2.7-minimal_2.7.18-8+deb11u1_amd64.deb python2.7-minimal_2.7.18-8+deb11u1_amd64.deb libpython2.7-stdlib_2.7.18-8+deb11u1_amd64.deb fadedbee@box:~/Downloads$ sudo dpkg -i libffi7_3.3-6_amd64.deb libssl1.1_1.1.1w-0+deb11u1_amd64.deb libpython2.7-minimal_2.7.18-8+deb11u1_amd64.deb python2.7-minimal_2.7.18-8+deb11u1_amd64.deb libpython2.7-stdlib_2.7.18-8+deb11u1_amd64.deb python2.7_2.7.18-8+deb11u1_amd64.deb [sudo] password for fadedbee: Selecting previously unselected package libffi7:amd64.
🌐
GitHub
gist.github.com › lukaslundgren › 2659457
How to install python 2.7 on debian · GitHub
This is not a good way to install Python on Debian. Chances are Python is already installed. The current stable release (Wheezy) comes with packages for "python2.7" and "python2.6".
Find elsewhere
🌐
Debian
packages.debian.org › python2
Debian -- Package Search Results -- python2
You have searched for packages that names contain python2 in all suites, all sections, and all architectures.
🌐
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 - sudo apt-get install wget wget https://bootstrap.pypa.io/pip/2.7/get-pip.py sudo python2.7 get-pip.py
🌐
LinuxShout
linux.how2shout.com › home › install python 3.x or 2.7 on debian 11 bullseye linux
Install Python 3.x or 2.7 on Debian 11 Bullseye Linux - LinuxShout
July 8, 2023 - However, the minimal Debian system users can go for the command given below. ... sudo apt install curl curl https://bootstrap.pypa.io/pip/2.7/get-pip.py --output get-pip.py sudo python2 get-pip.py pip2 --version or pip --version
🌐
California Learning Resource Network
clrn.org › home › how to install python2 on linux?
How to install python2 on Linux? - California Learning Resource Network
July 2, 2025 - The following steps outline the standard installation process for Python 2 on Debian/Ubuntu based systems.
🌐
The Hitchhiker's Guide to Python
docs.python-guide.org › starting › install › linux
Installing Python 2 on Linux — The Hitchhiker's Guide to Python
However, with the growing popularity of Python 3, some distributions, such as Fedora, don’t come with Python 2 pre-installed. You can install the python2 package with your distribution package manager:
🌐
Debian
packages.debian.org › bullseye › python-is-python2
Debian -- Details of package python-is-python2 in bullseye
This is a convenience package which ships a symlink to point /usr/bin/python interpreter at the current default python2. It may improve compatibility with obsolete 3rd-party software, whilst breaking some modern software. This package will be installed upon upgrades to Debian 11 (bullseye) ...
🌐
Super User
superuser.com › questions › 1792794 › installing-python-2-7-on-debian-12-in-a-virtualenv-or-other-options
Installing Python 2.7 on Debian 12 in a virtualenv (or other options) - Super User
July 1, 2023 - Recently I upgraded my system to Debian trixie, the current testing branch. But after the upgrade I discovered that Debian bookworm onwards does not include Python 2 at all. I understand that I may need to set it up in a container, or in some kind of virtualenv.
🌐
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 - If not installed, try: $ sudo zypper install python3-base ## get version 2.x ## $ sudo zypper install python2-base · Type the following command to display or check the Python version on your system: $ python --version Default Python version ...
🌐
Emacsos
blog.emacsos.com › pip2-in-debian-11-bullseye.html
Install pip for Python2.7 in Debian 11 Bullseye - Yuanle's blog
August 11, 2021 - Python 2.7 is still in Debian 11 Bullseye. But the python-pip package, which used to provide pip for python2, is gone. To get back pip for python 2.7, start a shell and run · wget https://bootstrap.pypa.io/pip/2.7/get-pip.py python2 get-pip.py · The command can be run as root user to install to system python2 site-packages, or as a normal user to install to current user's python2 site-packages.
🌐
Se7enSins
se7ensins.com › forums › technology & innovation › programming & scripting
How to install Python2.7 on Debian 12 | Se7enSins Gaming Community
March 12, 2024 - #!/bin/bash # Update System sudo apt update && sudo apt upgrade -y # Install Required Build Dependencies sudo apt install -y build-essential libssl-dev libncurses5-dev libncursesw5-dev libreadline-dev libsqlite3-dev libgdbm-dev libdb5.3-dev libbz2-dev libexpat1-dev liblzma-dev zlib1g-dev libffi-dev # Download Python 2.7 Source Code cd /tmp wget https://www.python.org/ftp/python/2.7.18/Python-2.7.18.tar.xz # Extract the Source Code tar -xf Python-2.7.18.tar.xz # Compile and Install Python 2.7 cd Python-2.7.18 ./configure --enable-optimizations make -j $(nproc) sudo make altinstall # Verify Python 2.7 Installation python2.7 --version Steps to use the script Copy the above script into a file, for example, install_python2.sh.