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 Overflowapt - How to install python2.7-dev package on vanilla debian 12? - Unix & Linux Stack Exchange
Need to install python 2. How do I accomplish this?
How do I install python 2.7
How to install python 2.7.17 ?
Videos
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
As my comment has solved the issue, I will develop it a little more in this answer for further reference.
Try using aptitude, it better manage conflicting packages for you:
Copysudo aptitude install python-minimal
Reference: https://askubuntu.com/a/451078/1006720
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).
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.
First, install some dependencies:
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
Then download using the following command:
version=2.7.13
cd ~/Downloads/
wget https://www.python.org/ftp/python/$version/Python-$version.tgz
Extract and go to the directory:
tar -xvf Python-$version.tgz
cd Python-$version
Now, install using the command you just tried, using checkinstall instead to make it easier to uninstall if needed:
./configure
make
sudo checkinstall
Change version to whichever version you need (version=2.7.1 or version=3.6.0, for example).
Unless you really have a burning desire to compile it yourself, the preferred way is to use the DeadSnakes PPA to install versions of Python that aren't included by default:
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update
sudo apt-get install python2.7
Other versions, such as python2.4 or python3.6, etc. are also available.
Running Mint 22 and I need to install python 2.7 because I'm trying to mod a leapster. I haven't found a way that works yet. If anyone reading this knows how to install SPECIFICALLY python 2.7, please let me know as soon as you can. Thanks!