How to Install Python 3.9 on Debian 9
In this article, we are going to install Python 3.9 on Debian 9 from source code.
Installing Python 3.9 on Debian from source code
First, check for any pending system updates.
apt update
apt upgrade
Install required packages to build Python.
apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev libsqlite3-dev wget libbz2-dev
Ouput:
root@vps:~# apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev libsqlite3-dev wget libbz2-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
wget is already the newest version (1.18-5+deb9u3).
The following additional packages will be installed:
binutils bzip2-doc cpp cpp-6 dpkg-dev fakeroot g++ g++-6 gcc gcc-6
libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl
libasan3 libatomic1 libc-dev-bin libc6-dev libcc1-0 libcilkrts5 libdpkg-perl
libfakeroot libfile-fcntllock-perl libgcc-6-dev libgomp1 libisl15 libitm1
liblsan0 libmpc3 libmpfr4 libmpx2 libnspr4 libnspr4-dev libnss3 libquadmath0
Download the Python 3.9 source code from python official site.
wget https://www.python.org/ftp/python/3.9.0/Python-3.9.0.tgz
Next, extract the archive file.
tar -xf Python-3.9.0.tgz
Change the directory to Python-3.9.0 and run the configure script.
cd Python-3.9.0
./configure --enable-optimizations
To start the Python 3.9 build process by running the following command.
make -j 12
Install the Python binaries.
make altinstall
To check the Python version.
python3.9 --version
Output:
root@vps:~# python3.9 --version
Python 3.9.0