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?

  • 8
    The default Debian repositories contains software packages specifically compiled for a certain Debian version. Except for security updates (preferably just the fewest changes needed to fix a security hole) new versions of most software may not be available until the next major release to avoid potential instability.
    – phk
    Commented Dec 25, 2016 at 8:09
  • @phk In that case, wouldn't it be prudent to adopt a behavior similar to pip, i.e. default to 3.4.2 when a version isn't specified, and allow the user to explicitly request 3.6 with a flag? Just an idea :)
    – davidtgq
    Commented Dec 25, 2016 at 10:48
  • 3
    This would mean that the Debian folks would have to maintain all these Python versions for every supported Debian version. Sure, it could be automated but it would be still a lot. Also, the power users who want newer versions could just as well use custom repositories. Sometimes ,the software authors themselves are maintaining them for Debian and other popular Linux distributions, e.g. in the case of Oracle VirtualBox.
    – phk
    Commented Dec 25, 2016 at 10:58
  • 1
    Python 3.6 (though rc1) just arrived in Debian experimental. It's probably possible to backport it to Jessie, possibly with a little tweaking. Commented Dec 26, 2016 at 8:16
  • Update. This finished building successfully for me on Debian stable (jessie). 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. Does anyone care? Commented Dec 26, 2016 at 9:35

9 Answers 9


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

wget https://www.python.org/ftp/python/3.6.9/Python-3.6.9.tgz
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: 
  • 6
    Don't debian guys recommend checkinstall? Otherwise, it would be wise to install it to /usr/local or /opt. Commented Jan 16, 2017 at 22:07
  • 4
    According to ./configure --help Python 3.6 installs to /usr/local per default. Commented May 4, 2017 at 21:03
  • 3
    Having trouble with this answer (e.g., SSL module not available or zlib missing)? See: stackoverflow.com/a/41601137/972128
    – kkurian
    Commented Jun 1, 2017 at 16:42
  • 16
    Disclaimer: this takes 20+ hours on a low powered device like the Pi zero. Commented Jul 12, 2017 at 7:06
  • 2
    version 3.7 is out
    – Timo
    Commented Mar 31, 2018 at 15:25

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

  • 9
    Don't try this - it will take you ages to undo Commented Dec 16, 2017 at 17:23
  • 1
    Is this still as risky to do as suggested in August (or Dec) 2017? It's not clear anymore after @cas edited and made his comment. Can someone follow up? Commented Jun 11, 2018 at 16:52
  • 2
    As of 9/15/2018 it is still risky: I tried this on a Raspberry Pi with Debian stretch and ran into segmentation faults after the Python 3.6 upgrade from testing pulled in an updated libc6 and libc6-dev.
    – drott
    Commented Sep 15, 2018 at 7:28
  • 2
    April 2019, still a "Bad Idea®©™", I did that yesterday, I should have been afraid of the long list of packages that would be removed, the system was in shambles, after reboot I didn't have X anymore, I didn't try to fix that and I installed Ubuntu.
    – lolesque
    Commented Apr 9, 2019 at 11:02
  • 3
    Please delete this dangerous answer omg
    – Daniel W.
    Commented May 9, 2019 at 13:30

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.

  • 5
    This follows general Python rule of "Practicality beats purity". I tend to install pythons from source packages in /opt/python-x.y.z and then run applications from its own virtualenvs.
    – zgoda
    Commented Jun 30, 2017 at 10:40
  • 1
    Important note: if you're going to do something like this: make sure that whatever user your Python process runs as can't modify the virtualenv Commented Aug 7, 2017 at 16:53
  • 2
    In my opinion this is the best answer. Commented Apr 11, 2018 at 17:05
  • Thank for this advice. In the past I broke some debian install with system wide addon.
    – freezed
    Commented Feb 11, 2019 at 14:27
  • In my install [venv]$ which python do not give me /home/<user>/pythonroot/bin/python, but /home/<user>/app/venv/bin/python3 instead… why?
    – freezed
    Commented Feb 11, 2019 at 15:01

You might want to have a look at pyenv : https://github.com/yyuu/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.

  • 3
    While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review
    – Archemar
    Commented Dec 25, 2016 at 10:36
  • You're right, will change the answer.
    – schaiba
    Commented Dec 25, 2016 at 10:40
  • 1
    I think he meant to also include the essential command lines too...
    – not2qubit
    Commented Mar 24, 2017 at 23:40
  • This works well, except when you're dealing with embedded devices. To "install" a version of python, the source is downloaded and compiled locally. Other than that, pyenv is a great choice and has lots of flexibility, including running different python versions in different directories, and dealing with the very annoying PIP problems. Commented Apr 16, 2017 at 6:29
  • 1
    pyenv don't impress me much. Its official installation process is 'cat this script to shell', and the script uses git and clones untagged code, and then it builds the python from scratch (so it needs a compiler, too). ¯_(ツ)_/¯
    – jrg
    Commented May 26, 2020 at 10:47

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.


wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh

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.

  • After endless problems with installing python from source, this version worked perfect! Note that if you want to work with virtualenv(wrapper) for the enviroment management, you need to add the miniconda library direcotry to LD_LIBRARY_PATH. Eg: add export $LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$HOME/miniconda3/lib" to your .bashrc.
    – jrast
    Commented Aug 11, 2017 at 23:38
  • "The installer also adds the path to your bashrc" That is the primary reason why I do not use anaconda. Silently masking an existing python environment is not healthy, to say the least. Commented Aug 28, 2017 at 6:59

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.


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.

With this

sudo echo "http://ftp.fr.debian.org/debian 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
  • Should read sudo echo "deb http://ftp.fr.debian.org/debian testing main" >> /etc/apt/sources.list
    – declension
    Commented Sep 28, 2018 at 11:28
  • 5
    This answer is the same as the accepted answer, came one year later, and yet fails at giving correct commands.
    – To마SE
    Commented Jan 16, 2019 at 7:16
  • There is python3.7 now in the testing
    – Serge S.
    Commented Jan 6, 2020 at 9:36

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.

  • 1
    "To upgrade python, first upgrade the world".This, whilst one way to do it, does not solve one's immediate problem.
    – jrg
    Commented May 26, 2020 at 10:50
  • GAD3R's answer very well covers how to install a later version of python without bricking your system like the accepted answer does. Upgrading the whole system is the only other alternative that comes to mind; it's a very different approach. Commented May 26, 2020 at 11:46
  • Interestingly the answer that “bricks your system” doesn’t seem to currently even let you do that, possibly due to repo changes as a result of Jessie going into the archive. But, having to install the compiler and developer libs is not always the path one wants to go down either.
    – jrg
    Commented May 27, 2020 at 12:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .