The use of Python to build applications from simple to enterprise level has proven its reliability and security. In this short article we will learn how to install Python 3.9 on Debian 11 operating system. Python is an interpreted high-level general-purpose programming language. Its design philosophy emphasizes code readability with its use of significant indentation. Its language constructs as well as its object-oriented approach aim to help programmers write clear, logical code for small and large-scale projects.
How To Install Python 3.9 On Debian 11
Prerequisites
Before we are going to the installation process we have to prepare the environment first as mentioned below :
- Debian 11 System with updated repository
- root or ordinary account with sudo privilege
- Sufficient disk space and good internet access
The Python 3.9 installation on Debian 11 will be consist of several steps, namely :
- Install Required Dependencies Packages
- Download Python 3.9
- Build and Install Python 3.9
- Verify Python 3.9
Detailed explanation of each item will be in the following sub-chapters
1. Install Required Dependencies Packages
The first step is to update our local packages software (repository) and installing the required essential dependencies for building Python 3.9. For this purpose we will submit the command line :
$ sudo apt update -y $ sudo apt upgrade -y
$ 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
2. Download and Extract Python 3.9 Archive File
Ithis step, we will download Python 3.9 source from Python Official website and extract it to an appropiate directory. For this purpose we will use wget command line, as shown below :
$ wget https://www.python.org/ftp/python/3.9.9/Python-3.9.9.tgz
Output :
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] After download is completed, then extract it by using tar command line.
After download is completed done, then we will extract it by using tar command line :
$ tar xvf Python-3.9.9.tgz
3. Build and Install Python 3.9
After extracting the Python 3.9 tarbal file, the we will build and install it by using command line :
$ cd Python-3.9.9 $ ./configure --enable-optimizations
Output :
ramansah@otodiginet:~$ cd Python-3.9.9 ramansah@otodiginet:~/Python-3.9.9$
ramansah@otodiginet:~/Python-3.9.9$ ./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 checking for --enable-universalsdk... no checking for --with-universal-archs... no checking MACHDEP... "linux" checking for gcc... gcc checking whether the C compiler works... yes checking for C compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... no checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ISO C89... none needed checking how to run the C preprocessor... gcc -E checking for grep that handles long lines and -e... /usr/bin/grep checking for a sed that does not truncate output... /usr/bin/sed checking for --with-cxx-main=<compiler>... no checking for g++... no configure: By default, distutils will build C++ extension modules with "g++". If this is not intended, then set CXX on the configure command line. .. Then we will make the file by using command line : $ sudo make altinstall
After installation is completed, then we will verify the Python installation by querying its version. We will submit the command line :
$ python3.9 --version Python 3.9.9
Conclusion
In this short article, we have tried to install Python 3.9 on Debian 11 operating system successfully.