January 26, 2022
How to install Python 3.9.9 on Debian 11

How To Install Python 3.9.9 On Debian 11

On this tutorial, we will learn how to install Python 3.9.9 on Debian 11 operating system.

Introduction

Python is a free, open-source interpreted high-level general-purpose programming language, that was originally released in 1991 Python 0.9.0. And since then it has experienced significant development, currently Python has reached version 3. Many applications are built using Python, for critical enterprises, desktops to mobile phones. In this article, we will discuss how to install Python version 3.9.9 on the Debian 11 operating system.

Python 3.9.9 Installation on Debian 11

On this tutorial, we will install Python 3.9.9 uses Python sources and make it with manual installation. So we have to download it first before installation is initiated. The installation process will be briefly described below.

  1. Updating Debian 11 System
  2. Install Required Dependencies Packages
  3. Download Pyton 3.9.9 Source
  4. Install Python 3.9.9

Prerequisite

There are several requirements that must be met before performing the installation, including:

  • A Debian 11 system with sufficient disk space
  • An account with sudo or root access to run privileged commands
  • Good internet connection for download packages

1. Update Debian 11 System

By updating Debian system, it will refresh the local list of available packages software to the newer stable version. To update Debian 11 repositories, we will use the command line:

$ sudo apt update -y
$ sudo apt upgrade -y
ramansah@otodiginet:~$ sudo apt update -y
[sudo] password for ramansah:
Hit:1 http://security.debian.org/debian-security bullseye-security InRelease                  
Hit:2 http://deb.debian.org/debian bullseye InRelease                                         
Hit:3 http://ftp.debian.org/debian stretch-backports InRelease                                
Hit:4 http://deb.debian.org/debian bullseye-updates InRelease    
ramansah@otodiginet:~$ sudo apt upgrade -y
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Calculating upgrade... Done
The following packages were automatically installed and are no longer required:
  libgnutls-dane0 libunbound8
Use 'sudo apt autoremove' to remove them.
The following NEW packages will be installed:
  linux-image-5.10.0-10-amd64
The following packages will be upgraded:
  base-files curl distro-info-data firefox-esr grafana im-config libayatana-indicator3-7
  libbrlapi0.8 libcurl3-gnutls libcurl4 libgmp10 libldb2 libnss3 libopennms-java
  libopennmsdeps-java libpq5 libseccomp2 libsmbclient libudisks2-0 libwbclient0
  linux-image-5.10.0-8-amd64 linux-image-amd64 nodejs openjdk-17-jdk openjdk-17-jdk-headless
  openjdk-17-jre openjdk-17-jre-headless opennms opennms-common opennms-db opennms-server
  opennms-source opennms-webapp-jetty postgresql-13 postgresql-client-13 publicsuffix
  python3-brlapi python3-ldb samba-libs udisks2 vim-common vim-tiny wget xbrlapi
  xserver-common xserver-xephyr xserver-xorg-core xserver-xorg-legacy xwayland xxd
50 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.

2. Install Required Dependencies Packages

On this step, we will install all required dependencies packages which is related to Pyhton 3.9 installation, for this purpose we will use the command line:

$ sudo apt install wget build-essential libreadline-dev
$ sudo apt install libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev
$ sudo apt install libc6-dev libbz2-dev libffi-dev zlib1g-dev -y

The complete view can be shown below :

ramansah@otodiginet:~$ sudo apt install wget build-essential libreadline-dev
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libgnutls-dane0 libunbound8
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  binutils binutils-common binutils-x86-64-linux-gnu dpkg-dev fakeroot g++ g++-10 gcc gcc-10
  libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl libasan6
  libatomic1 libbinutils libc-dev-bin libc-devtools libc6-dev libcc1-0 libcrypt-dev
  libctf-nobfd0 libctf0 libfakeroot libgcc-10-dev libitm1 liblsan0 libncurses-dev libnsl-dev
  libstdc++-10-dev libtirpc-dev libtsan0 libubsan1 linux-libc-dev manpages-dev
Suggested packages:
  binutils-doc debian-keyring g++-multilib g++-10-multilib gcc-10-doc gcc-multilib autoconf
  automake libtool flex bison gdb gcc-doc gcc-10-multilib gcc-10-locales glibc-doc
  ncurses-doc readline-doc libstdc++-10-doc
The following NEW packages will be installed:
  binutils binutils-common binutils-x86-64-linux-gnu build-essential dpkg-dev fakeroot g++
  g++-10 gcc gcc-10 libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl
  libasan6 libatomic1 libbinutils libc-dev-bin libc-devtools libc6-dev libcc1-0 libcrypt-dev
  libctf-nobfd0 libctf0 libfakeroot libgcc-10-dev libitm1 liblsan0 libncurses-dev libnsl-dev
  libreadline-dev libstdc++-10-dev libtirpc-dev libtsan0 libubsan1 linux-libc-dev
  manpages-dev
The following packages will be upgraded:
  wget
1 upgraded, 36 newly installed, 0 to remove and 49 not upgraded.
ramansah@otodiginet:~$ sudo apt install libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libgnutls-dane0 libunbound8
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  libbrotli-dev libexpat1-dev libfontconfig-dev libfontconfig1-dev libfreetype-dev libfreetype6-dev
  libpng-dev libpng-tools libtcl8.6 libtk8.6 libxext-dev libxft-dev libxrender-dev libxss-dev tcl
  tcl-dev tcl8.6 tcl8.6-dev tk tk8.6 tk8.6-dev uuid-dev x11proto-scrnsaver-dev x11proto-xext-dev
  zlib1g-dev
Suggested packages:
  freetype2-doc sqlite3-doc libssl-doc libxext-doc tcl-doc tcl-tclreadline tcl8.6-doc tk-doc tk8.6-doc
The following NEW packages will be installed:
  libbrotli-dev libexpat1-dev libfontconfig-dev libfontconfig1-dev libfreetype-dev libfreetype6-dev
  libgdbm-dev libncursesw5-dev libpng-dev libpng-tools libsqlite3-dev libssl-dev libtcl8.6 libtk8.6
  libxext-dev libxft-dev libxrender-dev libxss-dev tcl tcl-dev tcl8.6 tcl8.6-dev tk tk-dev tk8.6
  tk8.6-dev uuid-dev x11proto-scrnsaver-dev x11proto-xext-dev zlib1g-dev
0 upgraded, 30 newly installed, 0 to remove and 49 not upgraded.
ramansah@otodiginet:~$ sudo apt install libc6-dev libbz2-dev libffi-dev zlib1g-dev -y
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
libc6-dev is already the newest version (2.31-13+deb11u2).
libc6-dev set to manually installed.
zlib1g-dev is already the newest version (1:1.2.11.dfsg-2).
zlib1g-dev set to manually installed.
The following packages were automatically installed and are no longer required:
  libgnutls-dane0 libunbound8
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  bzip2-doc
The following NEW packages will be installed:
  bzip2-doc libbz2-dev libffi-dev
0 upgraded, 3 newly installed, 0 to remove and 49 not upgraded.
Need to get 601 kB of archives.
After this operation, 1,032 kB of additional disk space will be used.

3. Download Python 3.9.9

After required packages are installed on the system, the we will download the Python 3.9 source. for this purpser we will us the wget command line, as shown below. We will download, extract and install the Python 3.9.9 by using source file.

$ wget https://www.python.org/ftp/python/3.9.9/Python-3.9.9.tgz
$ tar xvf Python-3.9.9.tgz
ramansah@otodiginet:~$ wget https://www.python.org/ftp/python/3.9.9/Python-3.9.9.tgz
--2021-12-23 12:09:29--  https://www.python.org/ftp/python/3.9.9/Python-3.9.9.tgz
Resolving www.python.org (www.python.org)... 151.101.52.223
Connecting to www.python.org (www.python.org)|151.101.52.223|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 25787134 (25M) [application/octet-stream]
Saving to: ‘Python-3.9.9.tgz’

Python-3.9.9.tgz          100%[=====================================>]  24.59M   149KB/s    in 2m 8s   

2021-12-23 12:11:40 (197 KB/s) - ‘Python-3.9.9.tgz’ saved [25787134/25787134]
Download Python 3.9.9 Source file
Download Python 3.9.9 Source file

The Python source file will be located on the home directory, then we will extract it by using tar command line.

ramansah@otodiginet:~$ tar xvf Python-3.9.9.tgz
Python-3.9.9/
Python-3.9.9/Python/
Python-3.9.9/Python/pystrtod.c
..
Python-3.9.9/LICENSE
Python-3.9.9/.editorconfig
Python-3.9.9/CODE_OF_CONDUCT.md
Python-3.9.9/setup.py

4. Install Python 3.9.9

On this stage, after Python 3.9 source file has been extracted, then we will configure and make it by executing several command line as shown below.

$ cd Python-3.9.9
/Python-3.9.9$ sudo ./configure --enable-optimizations
/Python-3.9.9$ sudo make altinstall

Configuring extracted source file.

ramansah@otodiginet:~/Python-3.9.9$ sudo ./configure --enable-optimizations
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking for python3.9... python3.9
...
config.status: creating pyconfig.h
config.status: pyconfig.h is unchanged
creating Modules/Setup.local
creating Makefile

Make file

ramansah@otodiginet:~/Python-3.9.9$ sudo make altinstall
[sudo] password for ramansah:
gcc -pthread -c -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall    -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -fvisibility=hidden  -I./Include/internal  -I. -I./Include    -DPy_BUILD_CORE \
	-DABIFLAGS='""' \
	-DMULTIARCH=\"x86_64-linux-gnu\" \
	-o Python/sysmodule.o ./Python/sysmodule.c
...
  distutils: /usr/local/include/python3.9/pip
  sysconfig: /home/ramansah/Python-3.9.9/Include/pip
Successfully installed pip-21.2.4 setuptools-58.1.0
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
Executing make command line
Executing make command line

After make command line submitted and completed succesfully done, then we will verifty it by querying its version, by submitting command line :

ramansah@otodiginet:~/Python-3.9.9$ python3.9 --version
Python 3.9.9
Python version 3.9.9 has been installed on Debian 11
Python version 3.9.9 has been installed on Debian 11

Conclusion

On this article we have installed Python version 3.9 on Debian 11 BullEyes Operating system. I hope this article is useful for anyone who needs it. More detailed information about Python 3.9, can be found on the Python official website.

Share this article via :

Leave a Reply

Your email address will not be published. Required fields are marked *