Installing Python 2.7 on Debian 12 (Bookworm)

There is no Python 2 or Python 2.7 package in Debian 12 (Bookworm).

You can successfully install it from the Debian 11 (Bullseye) packages, but it has several dependecies which are also not provided by Debian 12 (Bookworm).

Note: I have been warned that this will create a Frankendebian. It is unlikely that Debian will release clashing Debian 12 (Bookworm) versions of libffi7, libssl1.1 or the python2.7 packages. Follow these instructions at your own risk and remove the packages as soon as you have finished using python2.7 and before upgrading to Debian 13.

Download these packages:

Install them with sudo dpkg -i <filenames>.

fadedbee@box:~$ lsb_release -a
No LSB modules are available.
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.
(Reading database ... 241776 files and directories currently installed.)
Preparing to unpack libffi7_3.3-6_amd64.deb ...
Unpacking libffi7:amd64 (3.3-6) ...
Selecting previously unselected package libssl1.1:amd64.
Preparing to unpack libssl1.1_1.1.1w-0+deb11u1_amd64.deb ...
Unpacking libssl1.1:amd64 (1.1.1w-0+deb11u1) ...
Selecting previously unselected package libpython2.7-minimal:amd64.
Preparing to unpack libpython2.7-minimal_2.7.18-8+deb11u1_amd64.deb ...
Unpacking libpython2.7-minimal:amd64 (2.7.18-8+deb11u1) ...
Selecting previously unselected package python2.7-minimal.
Preparing to unpack python2.7-minimal_2.7.18-8+deb11u1_amd64.deb ...
Unpacking python2.7-minimal (2.7.18-8+deb11u1) ...
Selecting previously unselected package libpython2.7-stdlib:amd64.
Preparing to unpack libpython2.7-stdlib_2.7.18-8+deb11u1_amd64.deb ...
Unpacking libpython2.7-stdlib:amd64 (2.7.18-8+deb11u1) ...
Selecting previously unselected package python2.7.
Preparing to unpack python2.7_2.7.18-8+deb11u1_amd64.deb ...
Unpacking python2.7 (2.7.18-8+deb11u1) ...
Setting up libffi7:amd64 (3.3-6) ...
Setting up libssl1.1:amd64 (1.1.1w-0+deb11u1) ...
Setting up libpython2.7-minimal:amd64 (2.7.18-8+deb11u1) ...
Setting up python2.7-minimal (2.7.18-8+deb11u1) ...
Linking and byte-compiling packages for runtime python2.7...
Setting up libpython2.7-stdlib:amd64 (2.7.18-8+deb11u1) ...
Setting up python2.7 (2.7.18-8+deb11u1) ...
Processing triggers for libc-bin (2.36-9+deb12u3) ...
Processing triggers for man-db (2.11.2-2) ...
Processing triggers for gnome-menus (3.36.0-1.1) ...
Processing triggers for desktop-file-utils (0.26-1) ...
Processing triggers for mailcap (3.70+nmu1) ...

fadedbee@box:~/Downloads$ python2.7
Python 2.7.18 (default, Sep 19 2023, 07:10:59) 
[GCC 10.2.1 20210110] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>