How to install Python 3.6?

I’d like to install the latest Python, which is 3.6 at the time of this post. However, the repository is saying that Python 3.4.2 is the newest version.

I’ve tried:

$ sudo apt-get update
$ sudo apt-get install python3

python3 is already the newest version.

$ python -V

Python 3.4.2

To upgrade to Python 3.6 on my Windows workstation, I simply downloaded an exe, clicked “next” a few times, and it’s done. What’s the proper and officially accepted procedure to install Python 3.6 on Debian Jessie?

Asked By: davidtgq


Debian does not have Python 3.6 in it’s repositories. Here’s a snapshot of the current Python3 status:

wheezy (oldstable) (python): interactive high-level object-oriented language (default python3 version)
    3.2.3-6: all
jessie (stable) (python): interactive high-level object-oriented language (default python3 version)
    3.4.2-2: amd64 arm64 armel armhf i386 mips mipsel powerpc ppc64el s390x
stretch (testing) (python): interactive high-level object-oriented language (default python3 version)
    3.5.1-4: amd64 arm64 armel armhf i386 mips mips64el mipsel ppc64el s390x
sid (unstable) (python): interactive high-level object-oriented language (default python3 version)
    3.5.1-4: alpha amd64 arm64 armel armhf hppa hurd-i386 i386 kfreebsd-amd64 kfreebsd-i386 m68k mips mips64el mipsel powerpc powerpcspe ppc64 ppc64el s390x sh4 sparc64 x32

You can check these out here.

You can install 3.6 either from source, or using something like Linuxbrew for a home directory installation.

Answered By: Dennis Chen

You might want to have a look at pyenv : . To quote from the pyenv tutorial at Amaral Lab:

Previously known as Pythonbrew, pyenv lets you change the global
Python version, install multiple Python versions, set directory
(project)-specific Python versions, and yes create/manage virtual
python environments (“virtualenvs”). All this is done on *NIX-style
machines (Linux and OS X) without depending on Python itself and it
works at the user-level–no need for any sudo commands.

Answered By: schaiba

You can install Python-3.6 on Debian 8 as follows:

tar xvf Python-3.6.9.tgz
cd Python-3.6.9
./configure --enable-optimizations --enable-shared
make -j8
sudo make altinstall

It is recommended to use make altinstall according to the official website.

If you want pip to be included, you need to add --with-ensurepip=install to your configure call. For more details see ./configure --help.

Warning: make install can overwrite or masquerade the python binary. make altinstall is therefore recommended instead of make install since it only installs exec_prefix/bin/pythonversion.

Some packages need to be installed to avoid some known problems, see: Common build problems(updated)


sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev 
libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev 
xz-utils tk-dev libffi-dev liblzma-dev

Alternative of libreadline-dev:

sudo apt install libedit-dev

Fedora/CentOS/RHEL(aws ec2):

sudo yum install zlib-devel bzip2 bzip2-devel readline-devel sqlite sqlite-devel 
openssl-devel xz xz-devel libffi-devel

Alternative of openssl-devel:

sudo yum install compat-openssl10-devel --allowerasing


You can download the latest python-x.y.z.tar.gz from here.

To set a default python version and easily switch between them , you need to update your update-alternatives with the multiple python version.

Let’s say you have installed the python3.7 on debian stretch , use the command whereis python to locate the binary (*/bin/python). e,g:


Add the python versions:

update-alternatives --install /usr/bin/python python /usr/local/bin/python3.7 50
update-alternatives --install /usr/bin/python python /usr/bin/python2.7 40
update-alternatives --install /usr/bin/python python /usr/bin/python3.5 30

The python3.7 with the 50 priority is now your default python , the python -V will print:

Python 3.7.0b2

To switch between them, use:

update-alternatives --config python

Sample output:

There are 3 choices for the alternative python (providing /usr/bin/python).

  Selection    Path                      Priority   Status
* 0            /usr/local/bin/python3.7   50        auto mode
  1            /usr/bin/python2.7         40        manual mode
  2            /usr/bin/python3.5         30        manual mode
  3            /usr/local/bin/python3.7   50        manual mode

Press <enter> to keep the current choice[*], or type selection number: 
Answered By: GAD3R

Python 3.6 (though rc1) just arrived in Debian experimental. I was able to successfully build this on Debian stable (jessie). See the final steps of the build pasted below.

However, that doesn’t mean it will install successfully and not cause problems. A reasonable next step would be to test it on a test VM of stable. If anyone cares, I could give it a try – or someone else could try.

A proper release version should arrive in Debian unstable shortly.

dh_builddeb -a
dpkg-deb: building package `python3.6' in `../python3.6_3.6.0~rc1-1_amd64.deb'.
dpkg-deb: building package `python3.6-venv' in `../python3.6-venv_3.6.0~rc1-1_amd64.deb'.
dpkg-deb: building package `libpython3.6-stdlib' in `../libpython3.6-stdlib_3.6.0~rc1-1_amd64.deb'.
dpkg-deb: building package `python3.6-minimal' in `../python3.6-minimal_3.6.0~rc1-1_amd64.deb'.
dpkg-deb: building package `libpython3.6-minimal' in `../libpython3.6-minimal_3.6.0~rc1-1_amd64.deb'.
dpkg-deb: building package `libpython3.6' in `../libpython3.6_3.6.0~rc1-1_amd64.deb'.
dpkg-deb: building package `python3.6-dev' in `../python3.6-dev_3.6.0~rc1-1_amd64.deb'.
dpkg-deb: building package `libpython3.6-dev' in `../libpython3.6-dev_3.6.0~rc1-1_amd64.deb'.
dpkg-deb: building package `python3.6-dbg' in `../python3.6-dbg_3.6.0~rc1-1_amd64.deb'.
dpkg-deb: building package `libpython3.6-dbg' in `../libpython3.6-dbg_3.6.0~rc1-1_amd64.deb'.
 dpkg-genchanges  >../python3.6_3.6.0~rc1-1_amd64.changes
dpkg-genchanges: including full source code in upload
 dpkg-source --after-build python3.6-3.6.0~rc1
dpkg-buildpackage: full upload (original source is included)
Now running lintian...
W: python3.6 source: newer-standards-version 3.9.8 (current is 3.9.6)
N: 56 tags overridden (26 errors, 27 warnings, 3 info)
Finished running lintian.
Answered By: Faheem Mitha

Editorial note:
Warning: this answer shows how to install Python from future releases of Debian. This will result in a system which mixes Debian releases, and will affect more than Python — in most cases, applying these instructions will pull in newer libraries too. The resulting setup won’t benefit from security updates with the same speed as might be expected, for packages which are updated. This is known as a FrankenDebian.

Consider the other answers to this question instead, in particular this one showing how to build from source, and this one showing how to use virtual environments.

Debian does not have Python 3.6 in its repositories, but testing has it.

$ sudo nano /etc/apt/sources.list
# add
deb testing main
$ echo 'APT::Default-Release "stable";' | sudo tee -a /etc/apt/apt.conf.d/00local
$ sudo apt-get update
$ sudo apt-get -t testing install python3.6
$ python3.6 -V

You asked for:

the proper and officially accepted procedure

but I must point it out that this is not official solution because it uses testing repositories.

The official recommendation is “you don’t actually need newer software”

Don’t suffer from Shiny New Stuff Syndrome – DontBreakDebian | Debian Wiki

Most of the advice on that page is geared towards what to do if you want the software to be available system-wide, but I don’t think that’s necessary in this case.

If you fetch the python sources, build the 3.6 interpreter using --prefix to control where it ends up, and then use virtualenv with the --python option, then you can use python 3.6 without affecting anything outside your project.

The process might go something like this:

$ cd ~
$ mkdir pythonroot
$ mkdir opt
$ mkdir app
$ cd opt
$ wget <python tarball>
$ tar -xvf <python tarball>
$ cd python-3.6
$ ./configure --prefix="$HOME"/pythonroot
$ make
$ make install
$ cd ~
$ cd app
$ virtualenv venv --python ~/pythonroot/bin/python
$ . venv/bin/activate
[venv]$ which python

If you’re going to do this, you may want to consider the --enable-optimizations flag in the Python configure script, which seems to enable some features like profile-guided optimization. It increases build times but seems to result in a faster interpreter by 10% or so according to some benchmarks.

Answered By: Greg Nisbet

My preferred way is to use Anaconda or Miniconda to keep the latest version of python and packages installed on Debian.

It’s all kept neatly in a folder which makes it very easy to remove later on if you wish. The installer also adds the path to your bashrc (add it yourself if you use another shell).

It comes with pip, and also conda which is another package manager than can be good for more complex pacakges like numpy. Miniconda is a bare bones install, and Anaconda is a full install with many packages, primarily designed for data analysis.



Read and accept license, if you’re not using bash add path: export PATH="/home/$USER/miniconda3/bin:$PATH"


$ python --version
Python 3.6.0 :: Continuum Analytics, Inc.

Install from PyPi:

# pip install fava

Install from conda:

# conda install numpy

When you want to delete it, remove the folder ~/miniconda3 and the path in your bashrc.

Answered By: alexjj

With this

sudo echo " testing main" >> /etc/apt/sources.list

sudo apt-get update
sudo apt-get install -y python3.6

Successfully work.

More : set python3.6 as default

sudo alias python=/usr/bin/python3.6

Right now :

python --version
Python 3.6
Answered By: Sean S

As of September 2019, the latest debian stable (buster) has python 3.7. So the proper and officially accepted procedure would now be to upgrade to debian buster.

Answered By: TamaMcGlinn