How to Install Python 3.6.4 on Debian 9

How to Install Python 3.6.4 on Debian 9

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

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:

# python3.6

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 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:

# python3.6

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.

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.

4 thoughts on “How to Install Python 3.6.4 on Debian 9”

  1. When executing “# make -j8” there were the following errors and the thread increments. Is it unsafe to proceed to the “make altinstall”?

    Exception in thread Thread-253:
    Traceback (most recent call last):
    File “/Python-3.6.4/Lib/”, line 83, in read
    File “/Python-3.6.4/Lib/test/”, line 366, in handle_read_event
    super(SSLConnection, self).handle_read_event()
    File “/Python-3.6.4/Lib/”, line 423, in handle_read_event
    File “/Python-3.6.4/Lib/”, line 171, in handle_read
    File “/Python-3.6.4/Lib/test/”, line 116, in found_terminator
    File “/Python-3.6.4/Lib/test/”, line 431, in cmd_auth
    File “/Python-3.6.4/Lib/test/”, line 315, in secure_connection
    ssl.SSLError: [SSL: EE_KEY_TOO_SMALL] ee key too small (_ssl.c:3337)

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
    File “/Python-3.6.4/Lib/”, line 916, in _bootstrap_inner
    File “/Python-3.6.4/Lib/test/”, line 279, in run
    asyncore.loop(timeout=0.1, count=1)
    File “/Python-3.6.4/Lib/”, line 207, in loop
    poll_fun(timeout, map)
    File “/Python-3.6.4/Lib/”, line 150, in poll
    File “/Python-3.6.4/Lib/”, line 87, in read
    File “/Python-3.6.4/Lib/test/”, line 399, in handle_error
    raise Exception

  2. make -j8 step failed @ -DPy_BUILD_CORE -o Python/mystrtoul.o Python/mystrtoul.c
    with the following error msg:

    gcc: internal compiler error: Killed (program cc1)
    Please submit a full bug report,
    with preprocessed source if appropriate.
    See for instructions.
    Makefile:1587: recipe for target ‘Objects/unicodeobject.o’ failed
    make[2]: *** [Objects/unicodeobject.o] Error 4
    make[2]: *** Waiting for unfinished jobs….
    make[2]: Leaving directory ‘/root/Python-3.6.4’
    Makefile:490: recipe for target ‘build_all_generate_profile’ failed
    make[1]: *** [build_all_generate_profile] Error 2
    make[1]: Leaving directory ‘/root/Python-3.6.4’
    Makefile:471: recipe for target ‘profile-opt’ failed
    make: *** [profile-opt] Error 2
    [email protected]:~/Python-3.6.4#

    Have not been able to find similar failure in FAQs etc.

    Beaglebone Black
    Debian 9: bone-debian-9.9-iot-armfh-2019-08-03-4gb.img.xz
    Running commands from PuTTY

    Help appreciated.


Leave a Comment

Move the slider all the way to the right to verify you are human. *