

The previous command should give you python3.6.5. ~/.bashrcĬonfirm the changes by checking your default python3 version: python3 -V You can also use python by changing the previous command to alias python='python3.6'. Once finished, open ~/.bashrc file using nano: sudo nano ~/.bashrcĪnd add new alias on the top of the file to change your default python executable: alias python3='python3.6' These steps took me around 4 hours on a Raspberry Pi 2 B. configure -enable-optimizations make -j -l 4 sudo make altinstall You just need to adjust the names accordingly.Īpt install libffi-dev libbz2-dev liblzma-dev libsqlite3-dev libncurses5-dev libgdbm-dev zlib1g-dev libreadline-dev libssl-dev tk-dev build-essential libncursesw5-dev libc6-dev openssl gitĭownload, build and install Python 3.6.5 (the most recent release is available on the official website): wget tar xf Python-3.6.5.tar.xz cd Python-3.6.5. Trust me, I had to (re)build/install it 3 times because I wanted to save a few minutes. Even if you already have Python 3.6 installed. If you are encountering the same SSL issues with pip and Python 3.6+ follow the steps below. I took me a few hours but I finally managed to fix the issue. But after the install I had the following error each time I wanted to install a library using pip pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available. Installing Python3.6 on Raspbian Stretch his a matter of few commands to copy/paste.

Everything was fine on my Mac as Python 3.6+ does this automatically so I wanted to have the same version on my Raspberry Pi (which was on Python 3.5). The news convinced me that it was the time to finally migrate the scripts I had running on my RPi to Python 3.Īdapting my code was an easy task except for the following annoying error when trying to load a JSON TypeError: the JSON object must be str, not 'bytes'. Make sure you download and build OpenSSL 1.1.1d first to assure Python would build with SSL correctly.Īfter years of faithful service Python 2.7 will not be maintained after January 1st, 2020. Update 3 January 2021: As mentioned by Rich Sadowsky in the comments the below also works for Python 3.9.
