How to install Python 3.5 on Raspbian Jessie

Head over to the RaspberryPi stackexchange and follow these instructions. To summarize:

sudo apt-get install build-essential libc6-dev
sudo apt-get install libncurses5-dev libncursesw5-dev libreadline6-dev
sudo apt-get install libdb5.3-dev libgdbm-dev libsqlite3-dev libssl-dev
sudo apt-get install libbz2-dev libexpat1-dev liblzma-dev zlib1g-dev
cd $HOME
wget https://www.python.org/ftp/python/3.8.6/Python-3.8.6.tgz
tar -zxvf Python-3.8.6.tgz
cd Python-3.8.6
./configure       # 3 min 13 s
# Let's use 4 threads
make -j4          # 8 min 29 s
sudo make install # ~ 4 min
cd ..
sudo rm -fr ./Python-3.8.6*
# upgrade:
sudo pip3 install -U pip
sudo pip3 install -U setuptools

(Note: he approximate times shown were measurements for the older python 3.5.2.)


The suggestion of @Padraic Cunningham to install libssl header files was helpful.

sudo apt-get install libssl-dev

But after this I further had to install GCC higher version 5 and CMake higher 3.5. The new Raspian Stretch comes with Python 3.5 and additionally with GCC 6.1 and CMake 3.5.

So the easiest way was to upgrade my system to Stretch (at the moment under test):

sudo echo 'deb http://mirrordirector.raspbian.org/raspbian/ testing main contrib non-free rpi' > /etc/apt/sources.list.d/stretch.list
sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get autoremove

This is quiet easy and always up to date. At the end this is my prefered solution :)