DEV Community

biprarshi
biprarshi

Posted on • Updated on

Installing Python-3.12.0 in Debian 12.2.0 (Bookworm)

Debian-12.2.0 comes with Python 3.11.2 but pip is not included.

Its necessary to install Python3 separately to use all features of python!

You can use the command in terminal to install Python3:

sudo apt-get install python3-full

But this will not install the latest version and will not provide full control over the installation process.

Using apt-get to install Python 3 will cause problems to install packages using pip.

Before installing Python 3 you need to download additional packages from https://www.debian.org/distrib/packages as given below:

libpkgconf3_1.8.1-1_amd64.deb
pkgconf-bin_1.8.1-1_amd64.deb
pkgconf_1.8.1-1_amd64.deb
pkg-config_1.8.1-1_amd64.deb

libffi-dev_3.4.4-1_amd64.deb

zlib1g_1.2.13.dfsg-1_amd64.deb
zlib1g-dev_1.2.13.dfsg-1_amd64.deb

libbabeltrace1_1.5.11-1+b2_amd64.deb
libdebuginfod-common_0.188-2.1_all.deb
libdebuginfod1_0.188-2.1_amd64.deb
libipt2_2.0.5-1_amd64.deb
libsource-highlight-common_3.1.9-4.2_all.deb
libboost-regex1.74.0_1.74.0+ds1-21_amd64.deb
libsource-highlight4v5_3.1.9-4.2+b3_amd64.deb
gdb_13.1-3_amd64.deb

Also note that pip doesn't work without openssl. So you also need to download it from https://www.openssl.org/source/

So lets get started!

Enter the following commands in terminal sequentially to install the dependencies:

  1. ~$ sudo dpkg -i libpkgconf3_1.8.1-1_amd64.deb pkgconf-bin_1.8.1-1_amd64.deb pkgconf_1.8.1-1_amd64.deb pkg-config_1.8.1-1_amd64.deb

  2. ~$ sudo dpkg -i libffi-dev_3.4.4-1_amd64.deb

  3. ~$ sudo dpkg -i zlib1g_1.2.13.dfsg-1_amd64.deb zlib1g-dev_1.2.13.dfsg-1_amd64.deb

  4. ~$ sudo dpkg -i libbabeltrace1_1.5.11-1+b2_amd64.deb libdebuginfod-common_0.188-2.1_all.deb libdebuginfod1_0.188-2.1_amd64.deb libipt2_2.0.5-1_amd64.deb libsource-highlight-common_3.1.9-4.2_all.deb libboost-regex1.74.0_1.74.0+ds1-21_amd64.deb libsource-highlight4v5_3.1.9-4.2+b3_amd64.deb gdb_13.1-3_amd64.deb

Install OpenSSL as follows sequentially:

  1. Extract the .tar.gz of source downloaded and enter the directory containing the source code like: ~$ cd openssl-3.1.4
  2. ~$ ./Configure
  3. ~$ make
  4. ~$ make test
  5. ~$ sudo make install

Finally! Install Python 3 as follows:

  1. Extract the .tar.gz of source downloaded and enter the directory containing the source code like: ~$ cd python 3.12.0
  2. ~$ ./configure --enable-optimizations
  3. ~$ make
  4. ~$ sudo make test (gives an error if 'sudo' not used with 'make test')
  5. ~$ sudo sudo make install

To update pip(optional):

~$ pip3 install --upgrade pip
OR
~$ python3 -m pip install --upgrade pip

Imortant: Don't forget to add the line

export PATH="/home/USER/.local/bin:$PATH"

to your .bashrc file (located in /home/USER/ directory) to add the /home/USER/.local/bin directory to your $PATH environment variable because the packages are installed by pip into this directory.

Thanks!

Top comments (0)