I would say there is no Debian equivalent to Ubuntu's deadsnakes PPA

Under Debian, using Ubuntu packages or repositories is not recommended. As this post appears in search engines, I propose here an answer that is less dangerous for a Debian system.

Installing Python manually is possible. As an example, you can use the following instructions to install 3.5.2 version

Prerequisites

Install dependencies :

sudo apt-get update && sudo apt-get install libssl-dev openssl

Building Python

You can build Python in a specific folder using the --prefix parameter from configure command:

wget https://www.python.org/ftp/python/3.5.2/Python-3.5.2.tgz
tar zxf Python-3.5.2.tgz
cd Python-3.5.2/
./configure --prefix=/usr/local
make
sudo make install

Instead of /usr/local, one can use another base directory. As an example:

sudo mkdir /opt/python-3.5.2
./configure --prefix=/opt/python-3.5.2

Selecting python version

Using PATH environment variable can help choosing the right python version to use. But one can also use symlinks:

sudo ln -s /opt/python-3.5.2/bin/python3.5 /usr/local/bin/python3
sudo ln -s /opt/python-3.5.2/bin/pip3.5 /usr/local/bin/pip3

Using -f option will allow you to replace existing symlinks


Note: For python 3.9.16 (possibly any +3.9 version) you also might need to install the library: libffi-dev so the dependencies would be:

sudo apt-get update && sudo apt-get install libssl-dev openssl libffi-dev
Answer from lauhub on Stack Exchange
Top answer
1 of 3
17

I would say there is no Debian equivalent to Ubuntu's deadsnakes PPA

Under Debian, using Ubuntu packages or repositories is not recommended. As this post appears in search engines, I propose here an answer that is less dangerous for a Debian system.

Installing Python manually is possible. As an example, you can use the following instructions to install 3.5.2 version

Prerequisites

Install dependencies :

sudo apt-get update && sudo apt-get install libssl-dev openssl

Building Python

You can build Python in a specific folder using the --prefix parameter from configure command:

wget https://www.python.org/ftp/python/3.5.2/Python-3.5.2.tgz
tar zxf Python-3.5.2.tgz
cd Python-3.5.2/
./configure --prefix=/usr/local
make
sudo make install

Instead of /usr/local, one can use another base directory. As an example:

sudo mkdir /opt/python-3.5.2
./configure --prefix=/opt/python-3.5.2

Selecting python version

Using PATH environment variable can help choosing the right python version to use. But one can also use symlinks:

sudo ln -s /opt/python-3.5.2/bin/python3.5 /usr/local/bin/python3
sudo ln -s /opt/python-3.5.2/bin/pip3.5 /usr/local/bin/pip3

Using -f option will allow you to replace existing symlinks


Note: For python 3.9.16 (possibly any +3.9 version) you also might need to install the library: libffi-dev so the dependencies would be:

sudo apt-get update && sudo apt-get install libssl-dev openssl libffi-dev
2 of 3
13

Using the PPA

You can use the PPA on Debian. Pick an Ubuntu version that's from slightly before your Debian version, and it should have all the necessary libraries. For wheezy, the oneiric PPA seems ok (but it lacks more recent Python versions). For jessie, the trusty PPA should work.

To add a PPA on Debian,

  1. Download and add the PPA signing key with:

    gpg --keyserver keyserver.ubuntu.com --recv-keys F23C5A6CF475977595C89F51BA6932366A755776
    gpg --export F23C5A6CF475977595C89F51BA6932366A755776 | sudo tee /usr/share/keyrings/ppa-deadsnakes.gpg > /dev/null
    
  2. Then create a file /etc/apt/sources.list.d/ppa-deadsnakes.list containing:

    deb [signed-by=/usr/share/keyrings/ppa-deadsnakes.gpg] https://ppa.launchpadcontent.net/deadsnakes/ppa/ubuntu/ trusty main 
    deb-src [signed-by=/usr/share/keyrings/ppa-deadsnakes.gpg] https://ppa.launchpadcontent.net/deadsnakes/ppa/ubuntu/ trusty main 
    
  3. Finally run apt-get update and install the desired packages.

If you can't get the PPA working for some reasons (maybe you can't find a version that works with the libraries you have), you can download the source and recompile them for your distribution.

Using a chrooted system

What I usually do to test compatibility with other versions is to run older or newer distributions in a chrooted system. For example, you could install various versions of Ubuntu with the Python versions you're interested in, or you could install trusty in a chroot and install the PPA there. For more information, see my schroot guide.

๐ŸŒ
Linode
linode.com โ€บ docs โ€บ guides โ€บ how-to-install-python-on-debian-10
How to Install Python 3 on Debian 10 | Linode Docs
February 12, 2021 - A fresh Debian 10 installation has both Python 2 and Python 3 installed by default. You can verify the specific versions of each by appending --version after typing python or python3 in the shell.
๐ŸŒ
Lxvs
lxvs.github.io โ€บ posts โ€บ install-old-python
How to Install an Old Version of Python in Debian or Ubuntu
August 19, 2023 - Say you want to install python 3.7.3, download the source tarball (note that the link is case sensitive). wget https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tgz ยท Feel free to browse Python official FTP for other versions.
Find elsewhere
๐ŸŒ
GitHub
gist.github.com โ€บ JonasAlfredsson โ€บ a73166b952e0a6469369474e940029c8
Install custom version of Python on a Debian system. ยท GitHub
export python_install_version="3.12.3" wget "https://www.python.org/ftp/python/${python_install_version}/Python-${python_install_version}.tgz" tar xvf "Python-${python_install_version}.tgz" && cd "Python-${python_install_version}" ./configure --enable-optimizations --with-lto=yes \ --enable-loadable-sqlite-extensions \ --enable-shared \ --prefix=/usr/local \ LDFLAGS="-Wl,-rpath /usr/local/lib" make -j$(nproc) sudo make altinstall
๐ŸŒ
Educative
educative.io โ€บ answers โ€บ how-to-install-a-specific-python-version-in-linux
How to install a specific Python version in Linux
We can check the default version of Python by running the command python --version. Open a terminal window and update the package list: ... Replace <version> with the version number you want to install.
๐ŸŒ
Vultr
docs.vultr.com โ€บ how-to-install-python-and-pip-on-debian-12
How to Install Python and Pip on Debian 12 Complete Guide | Vultr Docs
November 1, 2024 - ... Deploy a Debian 12 instance on Vultr. Access the instance using SSH. Create a non-root user with sudo privileges and switch to the user. Debian 12 comes with a specific version of Python pre-installed by default.
Top answer
1 of 3
11

Python has got its own package managing facilities, in parallel to the one sets by the Linux distributions (including Ubuntu). The repository is the Pypi - Python Package Index, and packages are installed with pip or the easy_install script, which is part of Python's setuptools package.

As a rule of thumb, you should not use both the packages installed via pip/setuptools, and packages available to your distro (via apt-get, yum, urpmi, etc...) as they might conflict.

So, one of the less error prone way to deal with it is to have separate Python installs in your system - leave the python that came with the system for system scripts and such - on this python, make use of packages installed by your package manager only. And install other versions of Python (or even the same), to be run with "virtualenv"s - on these other install you install things with pip/setuptools only.

(And even if one opt to live boldly and not use virtualenvs, installing another python version on the same prefix (/usr, and even /usr/local) than your system's Python is a source to confusing errors and conflicts).

Note that the Debian - and Ubuntu - systems devised a way to run parallel official Python's in /usr, and to have apt-get to install Python packages to both Python versions at once. This mostly works, but they mess with Python's default directory hierarchy, and some applications fail to use Python in this way. (It is also a mess to find the module files themselves in a Debian or Ubuntu). So the above method apply as a recommendation even if your system do have more than one version of Python available on apt-get.

In short, once you have compiled your desired version of Python, do this:

  1. use your system's package manager to install "python-setuptools" and "python-virtualenv" (not sure if these are the actual package names).
  2. Use virtualenv to create an environment from which you will use your different Python version
  3. Activate your virtualenv, and install Python packages using pip on it.

Virtualenv does feature a "--help" switch to help you, but you basically do:

Copy$ virtualenv -p <path-to-python-interpreter>  <environment-dir>
$ source <environment-dir>/bin/activate

And there you are - all things using Python will "see" the interpreter in the virtualenv, due to environment variables set.

2 of 3
6

ubuntu 10.04 doesn't have a python2.7 package. You have to build 2.7 yourself. I did read an article about ubuntu releasing a python2.7 package when 12.04 came out but i'm not sure what the repository location is.

http://eli.thegreenplace.net/2011/10/10/installing-python-2-7-on-ubuntu/

or:

Copysudo add-apt-repository ppa:fkrull/deadsnakes
sudo apt-get update
sudo apt-get install python2.7

https://askubuntu.com/questions/101591/install-python-2-7-2-on-ubuntu-10-04-64-bit

this question has lots of answers online.

๐ŸŒ
YouTube
youtube.com โ€บ k0nze
How to Install and Run Multiple Python Versions on Ubuntu/Debian | pyenv & virtualenv Setup Tutorial - YouTube
This video will show you how to install and run different Python versions on Ubuntu and Debian Linux using pyenv. You will learn to seamlessly switch between...
Published ย  September 25, 2021
Views ย  39K
๐ŸŒ
DigitalOcean
digitalocean.com โ€บ community โ€บ questions โ€บ how-to-install-a-specific-python-version-on-ubuntu
How to install a specific Python version on Ubuntu? | DigitalOcean
March 1, 2021 - This is going to be beyond the scope of the tutorial. However here is how you could install a specific version if needed: ... Finally you can create a symlink for that specific Python version so that you could use the binary from anywhere:
๐ŸŒ
Ruan Bekker's Blog
ruan.dev โ€บ blog โ€บ 2022 โ€บ 06 โ€บ 23 โ€บ install-a-specific-python-version-on-ubuntu
Install a specific Python version on Ubuntu | Ruan Bekker's Blog
June 23, 2022 - Head over to the Python Downloads section and select the version of your choice, in my case I will be using Python 3.8.13, once you have the download link, download it: $ wget https://www.python.org/ftp/python/3.8.13/Python-3.8.13.tgz ...
Top answer
1 of 3
27

Ok after a lot of searching I decided to build Python from source, so I downloaded the compressed source tarball from the Python download page, now we need to install the build-essential package to be able to compile the source files:

apt-get install build-essential

also we need to install these development packages which are required for some Python modules:

libbz2-dev
libsqlite3-dev
libreadline-dev
zlib1g-dev
libncurses5-dev
libssl-dev
libgdbm-dev

next we extract the downloaded source file:

tar zxf Python-2.7.6.tgz

then we cd into the extracted directory:

cd Python-2.7.6

and follow the instructions on the Python docs:

./configure --prefix=/opt/python
make
make install # <- in the docs but don't execute: use checkinstall

I chose to install it under the directory /opt/python which I created before, also I used the checkinstall package to create a .deb file so I can uninstall easily later, so we install it first:

apt-get install checkinstall

and substitute the last line make install with:

checkinstall

now I have a new python installation in /opt/python/lib/python2.7 and the binary file is in /opt/python/bin/python2.7.

now I can run in the command line /opt/python/bin/python2.7 to use this Python version, also we can make a link to this executable so we don't type the full path, I named it python2.7.6.

ln -s /opt/python/bin/python2.7 /usr/local/bin/python2.7.6

also the directory /opt/python/bin will contain later other executables like pip and virtualenv or any other modules you install so we can add it to the PATH environment variable, edit ~/.profile and add this line:

PATH="$PATH:/opt/python/bin"

and run:

source ~/.profile

I appended the path to the end because it contains executable names like the ones in /usr/bin like python, python2 and python2.7 so we keep the higher priority for /usr/bin.

2 of 3
16

You probably are looking for virtualenv or pyenv or some other non-system-wide method to install Python. The method using APT (Advance Package Tool) and dpkg, ensures that all parts of the system are working in harmony, so you maybe want to install python in a separated path, hidden of all the other programs that you can call at will, which is the purpose of pyenv/virtualenv. This answers how to install the latest version of python without breaking the system.

BTW, you can check out the latest version of python that Debian in madison, while the latest version of python 2 at the date is the one you pointed out:

โžœ  ~  apt-cache policy python
python:
  Installed: 2.7.5-5
  Candidate: 2.7.5-5
  Version table:
 *** 2.7.5-5 0
        500 http://ftp.us.debian.org/debian/ testing/main i386 Packages
        100 /var/lib/dpkg/status

(pythonbrew is not longer maintained).

๐ŸŒ
DropVPS
dropvps.com โ€บ home โ€บ blog โ€บ how to change python version on debian 12
how to change python version on Debian 12
November 4, 2025 - Debian allows you to manage multiple versions using the update-alternatives system. sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 1
๐ŸŒ
Quora
quora.com โ€บ How-can-one-install-a-specific-version-of-Python-in-Ubuntu
How can one install a specific version of Python in Ubuntu? - Quora
Answer (1 of 5): Yes we can install any specific version of Python. First install dependencies: [code]sudo apt-get install build-essential checkinstall sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev [/code]Then downl...
๐ŸŒ
Debian
wiki.debian.org โ€บ Python โ€บ FAQ
Python/FAQ - Debian Wiki
August 10, 2025 - However we want to make the "egg meta-information" available so that users can use eggs if they so wish. Python >= 2.5 does that by default in distutils. For setuptools based setup.py you need to pass the option "--single-version-externally-managed" to the "setup.py install" call.
๐ŸŒ
FOSS Linux
fosslinux.com โ€บ home โ€บ linux distributions โ€บ debian & ubuntu โ€บ debian โ€บ the complete guide to installing and managing python on debian (2026)
How to Install Python on Debian 12/13: The Definitive Guide
April 19, 2026 - If you have recently tried to install a package on Debian 12 or 13 using pip install, you likely encountered the error: externally-managed-environment. This is a deliberate protection mechanism. Debian is notifying you that the systemโ€™s Python environment is managed by the APT package manager, and installing packages with pip could lead to version conflicts with critical system tools.