Installing Python 3.6.2 on raspberry pi (raspbian)



As of September 2017 Raspbian does not yet include Python 3.6. To install it you need to compile the source code.

Install requirements

a1. Install the required build-tools (some might already be installed on your system).

sudo apt-get update
sudo apt-get install build-essential tk-dev libncurses5-dev libncursesw5-dev libreadline6-dev libdb5.3-dev libgdbm-dev libsqlite3-dev libssl-dev libbz2-dev libexpat1-dev liblzma-dev zlib1g-dev

Download and compilation of Python 3.6.2

  1. Download and install Python 3.6. When downloading the source code, select the most recent release of Python 3.6, available on the (official site)[https://www.python.org/downloads/source/].
wget https://www.python.org/ftp/python/3.6.2/Python-3.6.2.tar.xz
tar xf Python-3.6.2.tar.xz
cd Python-3.6.2
./configure --enable-optimizations
sudo make altinstall


You can now delete the source code and uninstall the previously installed packages. When uninstalling the packages, make sure you only remove those that were not previously installed on your system. Also, remember to adjust version numbers if necesarry.

.. code-block:: bash

sudo rm -r Python-3.6.0
rm Python-3.6.0.tgz
sudo apt-get --purge remove build-essential tk-dev
sudo apt-get --purge remove libncurses5-dev libncursesw5-dev libreadline6-dev
sudo apt-get --purge remove libdb5.3-dev libgdbm-dev libsqlite3-dev libssl-dev
sudo apt-get --purge remove libbz2-dev libexpat1-dev liblzma-dev zlib1g-dev
sudo apt-get autoremove
sudo apt-get clean