25.4 C
Texas
angeloma
Senior Writer and partner

How to install Python 3.9 on Debian 10?

Hi, folks. Debian 10 has been with us for a while now and some of its packages are starting to get old, including Python. In this post, I will show you how to install Python 3.9 on Debian 10

Python is one of the most popular programming languages out there. Its incredible versatility makes it be in almost any technology field. In addition, its learning curve is quite low which makes it ideal for learning.

The truth is that Debian 10 is in its best moment of stability, but also some of its packages are starting to get old. That’s why some people update some of them individually. Especially the most important ones for work.

Therefore, if a developer wants to take advantage of the features of Python 3.9 in Debian 10, he has to update it.

- Advertisement -

So let’s go for it.

Install Python 3.9 on Debian 10

Debian 10 comes with Python 3.6 by default. It’s a good version but it’s starting to get a bit outdated. However, its dependencies will help us install the new version of Python.

So, first, enable the source code repository in APT. This repository will help us to install all the dependencies of Python 3.9 in a very easy way.

To do this, open a terminal and edit the APT source file.

:~$ sudo nano /etc/apt/sources.list

And check that the next line is not already enabled:

deb-src http://deb.debian.org/debian buster main contrib non-free

If it’s not in the file, add it.

1.- enable the source packages
1.- enable the source packages

Then save the changes with CTRL + O and close the file with CTRL + X.

Note: in my case, I’m using an alternative mirror to the official one.

Next, update the APT cache to recognize the added repository.

:~$ sudo apt update

And with the following command, you install all the dependencies of Python 3.7 which are the same for Python 3.9

sudo apt-get build-dep python3.7
Reading package lists... Done
Reading package lists... Done
Building dependency tree 
Reading state information... Done
The following NEW packages will be installed:
autoconf automake autopoint autotools-dev binutils binutils-common binutils-x86-64-linux-gnu blt-dev build-essential cpp cpp-8 debhelper dh-autoreconf
dh-strip-nondeterminism diffstat docutils-common dpkg-dev dwz fontconfig-config fonts-dejavu-core g++ g++-8 gcc gcc-8 gettext intltool-debian libarchive-zip-perl
libasan5 libatomic1 libbinutils libbluetooth-dev libbluetooth3 libbz2-dev libc-dev-bin libc6-dev libcc1-0 libcroco3 libdb-dev libdb5.3-dev libdpkg-perl
libdrm-amdgpu1 libdrm-common libdrm-intel1 libdrm-nouveau2 libdrm-radeon1 libdrm2 libexpat1-dev libffi-dev libfile-stripnondeterminism-perl libfontconfig1
libfontconfig1-dev libfontenc1 libfreetype6-dev libgcc-8-dev libgdbm-compat4 libgdbm-dev libgl1 libgl1-mesa-dri libglapi-mesa libglvnd0 libglx-mesa0 libglx0 libgomp1
libgpm2 libice-dev libice6 libisl19 libitm1 libjs-jquery libjs-sphinxdoc libjs-underscore libllvm7 liblsan0 liblzma-dev libmpc3 libmpdec-dev libmpfr6 libmpx2
libncurses-dev libncursesw5-dev libpciaccess0 libperl5.28 libpixman-1-0 libpng-dev libpthread-stubs0-dev libquadmath0 libreadline-dev libsensors-config libsensors5
libsigsegv2 libsm-dev libsm6 libsqlite3-dev libssl-dev libstdc++-8-dev libtcl8.6 libtext-unidecode-perl libtk8.6 libtool libtsan0 libubsan1 libunwind8 libx11-6
libx11-data libx11-dev libx11-xcb1 libxau-dev libxau6 libxaw7 libxcb-dri2-0 libxcb-dri3-0 libxcb-glx0 libxcb-present0 libxcb-sync1 libxcb1 libxcb1-dev libxdamage1
libxdmcp-dev libxdmcp6 libxext-dev libxext6 libxfixes3 libxfont2 libxft-dev libxft2 libxkbfile1 libxml-libxml-perl libxml-namespacesupport-perl libxml-sax-base-perl
libxml-sax-perl libxmu6 libxmuu1 libxpm4 libxrender-dev libxrender1 libxshmfence1 libxss-dev libxss1 libxt-dev libxt6 libxxf86vm1 linux-libc-dev m4 make perl
pkg-config po-debconf python-babel-localedata python3-alabaster python3-babel python3-distutils python3-docutils python3-imagesize python3-lib2to3 python3-packaging
python3-pygments python3-pyparsing python3-roman python3-sphinx python3-tz quilt sgml-base sharutils sphinx-common tcl tcl-dev tcl8.6 tcl8.6-dev tex-common texinfo
time tk tk-dev tk8.6 tk8.6-blt2.5 tk8.6-dev uuid-dev x11-common x11-xkb-utils x11proto-core-dev x11proto-dev x11proto-scrnsaver-dev x11proto-xext-dev xauth xml-core
xorg-sgml-doctools xserver-common xtrans-dev xvfb zlib1g-dev
The following packages will be upgraded:
libssl1.1
1 upgraded, 190 newly installed, 0 to remove and 24 not upgraded.
Need to get 114 MB of archives.
After this operation, 567 MB of additional disk space will be used.
Do you want to continue? [Y/n]

2.- Installing the Python 3.9 dependencies
2.- Installing the Python 3.9 dependencies

Then, download Python 3.9.

:~$ cd /tmp
:~$ sudo wget https://www.python.org/ftp/python/3.9.2/Python-3.9.2.tgz

After that, decompress the file.

:~$ tar xzvf Python-3.9.2.tgz

Now access the generated folder and start the configuration.

:~$ cd Python-3.9.2/
:~$ sudo ./configure --enable-optimizations

3.- Configuring python on Ubuntu
3.- Configuring python on Ubuntu

The --enable-optimizations parameter is used to obtain an optimized Python construction. It is optional but recommended.

Now you can start the installation. But instead of using make install, we’ll use another one to avoid it replacing the version that already comes with Ubuntu. This increases the robustness and allows you to have several versions of Python.

:~$ sudo make altinstall

4.- Installing python 3.9 on Debian 10
4.- Installing python 3.9 on Debian 10

The installation will start at the end and you will have Python 3.9 ready for action.

If you want to verify, you can use the following command:

:~$ python3.9 -V
Python 3.9.2

So, enjoy it.

Conclusion

Python is very popular and many developers always want to have the latest to create their applications. That’s why it is often convenient to have the latest version of Python.

Please share this post and join our Telegram channel.

More info here.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest article