Python is an interpreted, high-level, general-purpose programming language that lets you work more quickly and integrate your systems more effectively. Python is developed under an OSI-approved open source license, making it freely usable and distributable, even for commercial use. Python's license is administered by the Python Software Foundation.

In this guide, we will explain how to install Python 3 on Debian 9.

Deploying your cloud server
If you have not already registered with Cloudwafer, you should begin by getting signed up. Take a moment to create an account after which you can quickly deploy your cloud servers.

Once you have signed up, log into your Cloudwafer Client Area and deploy your Cloudwafer cloud server.

Updating System Packages
It is recommended that you update the system to the latest packages before beginning any major installations. Issue the command below:

sudo apt-get update && sudo apt-get upgrade

Step 1: Check Default Python Version
To check the default python version currently installed on your server, issue the command below:

python --version

Step 2: Install the necessary packages
Issue the command below to install the necessary packages required for building python.

sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev wget

Step 3: Download Python's source code

Issue the command below to download the latest release’s source code from the Python download page using the following curl command. The latest version at the time of writing this article is 3.8.0.

curl -O https://www.python.org/ftp/python/3.8.0/Python-3.8.0.tar.xz  

After downloading, extract using the command below:

tar -xf Python-3.8.0.tar.xz  

Next, change to the Python source directory and run the configure script as shown below:

cd Python-3.8.0
./configure --enable-optimizations

Next, run make to start the build process:

make

After completing the build process, install the Python binaries by issuing the command below:

sudo make altinstall

Verify the installation by typing:

python3.8 --version