Python is a interactive and object-oriented scripting language. It is one of the most popular programming languages. Python is a general-purpose programming language designed to be highly readable. It is using English keywords instead of punctuation and it also has fewer syntactical constructions than other programming languages and it allows developers to use different programming styles for creating their programs, and write code almost as if speaking in a human language.
Installing Python 3.6.4 on a Debian VPS, is an easy task, just follow the steps below carefully and you should have Python 3.6.4 on Debian 9 installed in few minutes.
Update the system
As usual update all the system packages before continuing to work on your server:
# sudo apt-get update && sudo apt-get upgrade
Installing Python 3.6.4 from source
Now we’ll build and install Python 3.6.4 from source, this is the safest and recommended way that doesn’t add any repositories that might install conflicting packages on your Debian 9 server.
Begin by installing the required build tools for Python 3.6.4:
# sudo apt-get install -y make build-essential libssl-dev zlib1g-dev # sudo apt-get install -y libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm # sudo apt-get install -y libncurses5-dev libncursesw5-dev xz-utils tk-dev
Download the Python 3.6.4 source file using ‘wget’:
# wget https://www.python.org/ftp/python/3.6.4/Python-3.6.4.tgz
Unpack the Python 3.6.4 source file:
# tar xvf Python-3.6.4.tgz
Enter the Python-3.6.4 directory and run ‘./configure’ to prepare the build:
# cd Python-3.6.4 # ./configure --enable-optimizations
Then run the following command to build Python 3.6.4:
# make -j8
And then run this command to install Python 3.6.4:
# sudo make altinstall
Now you can open the Python 3.6.4 interpreter by executing the following command:
Installing Python 3.6.4 from the Debian testing repository
This way of installing Python 3.6.4 is not recommended because it may install/upgrade packages from the Debian ‘testing’ repository which are incompatible with your current Debian 9 installation. If you want to install Python 3.6.4 using the Debian ‘testing’ repository make sure to try this on a test machine first to see if any of the packages fail to install or if there are any conflicts after installing the packages required for Python 3.6.4.
Begin by editing the ‘/etc/apt/sources.list’ file with your favorite editor(we’ll use nano) and add the line below at the bottom of the file:
# sudo nano /etc/apt/sources.list deb http://ftp.de.debian.org/debian testing main
Then execute the following command to make the ‘stable’ repository default on your server:
# echo 'APT::Default-Release "stable";' | sudo tee -a /etc/apt/apt.conf.d/00local
Now update the package list:
# sudo apt-get update
And install Python 3.6.4 from the Debian ‘testing’ repository using the following command:
# sudo apt-get -t testing install python3.6
If everything went well, run the following command to open the Python 3.6.4 interpreter:
That’s it, now you should have Python 3.6.4 installed on your server.
Of course, you don’t have to install Python 3.6.4 on your Debian 9 VPS, if you use one of our high-speed Python VPS hosting services – in which case you can simply ask our expert Linux admins to install Python 3.6.4 for you. They are available 24×7 and will take care of your request immediately.
We also have a tutorial on how to install Python 3.9 on Debian 10, so if you want to update the latest versions, feel free to check it out.
PS. If you liked this post on how to install Python 3.6.4 on Debian 9, please share it with your friends through the social networks by using the buttons on the left, or simply leave a reply below. Thanks.