Bobcares

How to Install Python 3.9 on Debian 10

by | May 12, 2021

Wondering how to install Python 3.9 on Debian 10? We can help you.

As part of our Server Management Services, we assist our customers with several installation queries.

Today, let us see how our Support Techs install Python.

How to Install Python 3.9 on Debian 10

Python is a programming and scripting language developed under open source license, making it freely usable and distributable, even for commercial use.

Firstly, in Python development journey is the software installation. By default, Debian 10 comes with Python version 3.7. In this article, let us see how Linux users can install Python 3.9 on Debian 10 system.

Compiling Python from the source allows to install the latest Python version and customize the build options.

  • Firstly, update APT cache index before installing Python 3.9 on Debian 10 system.
$ sudo apt update

If upgrade is possible, then run the commands below.

$ sudo apt upgrade -y
  • Then, restart the system after a successful upgrade.
$ sudo reboot
  • After the system is rebooted, install dependency packages:
$ sudo apt install wget software-properties-common build-essential libnss3-dev zlib1g-dev libgdbm-dev libncurses5-dev libssl-dev libffi-dev libreadline-dev libsqlite3-dev libbz2-dev

 

Hit the y key to begin installation:

0 upgraded, 95 newly installed, 0 to remove and 0 not upgraded.
Need to get 74.7 MB of archives.
After this operation, 296 MB of additional disk space will be used.
Do you want to continue? [Y/n] y

Then, visit Python Downloads page and pull the latest release.

$ wget https://www.python.org/ftp/python/3.9.2/Python-3.9.2.tgz

Extract the downloaded file.

$$ tar xvf Python-3.9.2.tgz

Change working directory to create Python folder:

$ cd Python-3.9.2/

Run configuration command:

$ ./configure –enable-optimizations

Sample output:

….
checking for shm_open… yes
checking for shm_unlink… yes
checking for pkg-config… no
checking for openssl/ssl.h in /usr/local/ssl… no
checking for openssl/ssl.h in /usr/lib/ssl… no
checking for openssl/ssl.h in /usr/ssl… no
checking for openssl/ssl.h in /usr/pkg… no
checking for openssl/ssl.h in /usr/local… no
checking for openssl/ssl.h in /usr… no
checking whether compiling and linking against OpenSSL works… no
checking for –with-ssl-default-suites… python
checking for –with-builtin-hashlib-hashes… md5,sha1,sha256,sha512,sha3,blake2
configure: creating ./config.status
config.status: creating Makefile.pre
config.status: creating Misc/python.pc
config.status: creating Misc/python-embed.pc
config.status: creating Misc/python-config.sh
config.status: creating Modules/ld_so_aix
config.status: creating pyconfig.h
config.status: pyconfig.h is unchanged
creating Modules/Setup.local
creating Makefile

 

Build Python 3.9 on Debian 10 Linux:

$ sudo make altinstall

Usually, a successful installation will have output similar to below:

….
changing mode of /usr/local/lib/python3.9/lib-dynload/__pycache__ to 755
running install_scripts
copying build/scripts-3.9/idle3.9 -> /usr/local/bin
copying build/scripts-3.9/pydoc3.9 -> /usr/local/bin
copying build/scripts-3.9/2to3-3.9 -> /usr/local/bin
changing mode of /usr/local/bin/idle3.9 to 755
changing mode of /usr/local/bin/pydoc3.9 to 755
changing mode of /usr/local/bin/2to3-3.9 to 755
rm /usr/local/lib/python3.9/lib-dynload/_sysconfigdata__linux_x86_64-linux-gnu.py
rm -r /usr/local/lib/python3.9/lib-dynload/__pycache__
/usr/bin/install -c -m 644 ./Misc/python.man \
/usr/local/share/man/man1/python3.9.1
if test “xupgrade” != “xno” ; then \
case upgrade in \
upgrade) ensurepip=”–altinstall –upgrade” ;; \
install|*) ensurepip=”–altinstall” ;; \
esac; \
./python -E -m ensurepip \
$ensurepip –root=/ ; \
fi
Looking in links: /tmp/tmpog4qrruc
Requirement already up-to-date: setuptools in /usr/local/lib/python3.9/site-packages (49.2.1)
Requirement already up-to-date: pip in /usr/local/lib/python3.9/site-packages (20.2.3)

Then, running the commands below will output the version of Python 3.9 available in our system:

$ python3.9 –version
Python 3.9.2

Finally, to install Python modules available in modules releases page, use the command syntax:

$ python3.9 -m pip install <module>

 

Install Python 3.9 on Debian 10 with Apt

First and foremost, it is very simple and straightforward process to install Python 3.9 on Debian using the apt packages manager.

Step 1: Firstly, update packages list

First, update the packages list and install required dependencies:

$ sudo apt update
$ sudo apt install software-properties-common

Step 2: Enable Repository

Then, add the deadsnakes PPA to system’s sources list by typing:

$ sudo add-apt-repository ppa:deadsnakes/ppa

Hit the Enter when we get prompt.

Step 3: Install Python 3.9

Once the repository is enabled, we can install the Python 3.9 by running the below command:

$ sudo apt update
$ sudo apt install python3.9

Step 4: Finally, verify Installation

To verify the installation, execute the command:

$ python3.9 –version
Python 3.9.0+

At this stage, the Python 3.9 is installed on Debian 10 system.

Upgrade from Python 3.7 to 3.9 in Debian 10

In order to, upgrade the version of Python from 3.7 to 3.9, we need to add Debian’s testing repositories.

Open the /etc/apt/sources.list file with the following command:

$ sudo nano /etc/apt/sources.list

Add the official testing repository. Append the following line of text to the end of the file:

$ deb http://http.us.debian.org/debian/ testing non-free contrib main

Our file should match this:

File: /etc/apt/sources.list
deb http://mirrors.linode.com/debian buster main
deb-src http://mirrors.linode.com/debian buster main

deb http://mirrors.linode.com/debian-security buster/updates main
deb-src http://mirrors.linode.com/debian-security buster/updates main

# buster-updates, previously known as ‘volatile’
deb http://mirrors.linode.com/debian buster-updates main
deb-src http://mirrors.linode.com/debian buster-updates main

# Debian Testing Non-Free

deb http://http.us.debian.org/debian/ testing non-free contrib main

After editing the file, download the information for all of the packages available with the following command:

$ sudo apt update

Upgrade Python 3 with the following command:

$ sudo apt upgrade python3

Because Python3 requires a lot of dependencies, we are prompted to allow Debian to restart certain services. If we are not running any active processes, this is okay. Otherwise, we may decide to restart the services ourselves.

Verify that we have updated Python by checking the version:

$ python3 –version

Python 3.9.1

Now Debian 10 system has the latest version of Python 3 installed.

[Need any further assistance to fix CyberPanel errors? – We’re available 24*7]

Conclusion

In short, Python is a programming and scripting language developed under open source license, making it freely usable and distributable, even for commercial use. Today, we saw how our Support techs assist with Python installation.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

0 Comments

Submit a Comment

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

Never again lose customers to poor
server speed! Let us help you.