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.

install python 364 on debian 9

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:

# 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 http://ftp.de.debian.org/debian testing main

Then execute the following command to make the ‘stable’ repository default on your server:

Need a fast and easy fix?
✔ Unlimited Managed Support
✔ Supports Your Software
✔ 2 CPU Cores
✔ 2 GB RAM
✔ 50 GB PCIe4 NVMe Disk
✔ 1854 GeekBench Score
✔ Unmetered Data Transfer
NVME 2 VPS

Now just $43 .99
/mo

GET YOUR VPS
# 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.

installing python 364 on debian 9

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 social networks 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/asyncore.py”, line 83, in read
    obj.handle_read_event()
    File “/Python-3.6.4/Lib/test/test_ftplib.py”, line 366, in handle_read_event
    super(SSLConnection, self).handle_read_event()
    File “/Python-3.6.4/Lib/asyncore.py”, line 423, in handle_read_event
    self.handle_read()
    File “/Python-3.6.4/Lib/asynchat.py”, line 171, in handle_read
    self.found_terminator()
    File “/Python-3.6.4/Lib/test/test_ftplib.py”, line 116, in found_terminator
    method(arg)
    File “/Python-3.6.4/Lib/test/test_ftplib.py”, line 431, in cmd_auth
    self.secure_connection()
    File “/Python-3.6.4/Lib/test/test_ftplib.py”, line 315, in secure_connection
    context.load_cert_chain(CERTFILE)
    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/threading.py”, line 916, in _bootstrap_inner
    self.run()
    File “/Python-3.6.4/Lib/test/test_ftplib.py”, line 279, in run
    asyncore.loop(timeout=0.1, count=1)
    File “/Python-3.6.4/Lib/asyncore.py”, line 207, in loop
    poll_fun(timeout, map)
    File “/Python-3.6.4/Lib/asyncore.py”, line 150, in poll
    read(obj)
    File “/Python-3.6.4/Lib/asyncore.py”, line 87, in read
    obj.handle_error()
    File “/Python-3.6.4/Lib/test/test_ftplib.py”, line 399, in handle_error
    raise Exception
    Exception

    Reply
  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
    root@beaglebone:~/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.

    Reply
    • This can happen if your server runs out of memory.

      Make sure you have enough free memory on your server while compiling gcc.

      Reply

Leave a Comment