How to install Python 3.7 on Raspberry PI (Raspbian)

In this tutorial, I will show you how to install Python 3.7 on Raspberry Pi running raspbian on it.

Update the Raspbian

Update the Raspbian before installing python.

sudo apt-get update

Read Also: How to install python 3.7 on Ubuntu 16.04 / 18.04

Prerequisites

Before installing python 3.7 there are some dependencies that we need to install. Use the following command to install the required dependencies.

sudo apt-get install -y 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 libffi-dev

Download Python

You can download Python from the official website or use the following command.

wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tgz

Read Also: How to install postgresql 11 on Debian 8 / 9

Install Python 3.7 On Raspberry Pi

Now we will extract and install Python from source.
sudo tar zxf Python-3.7.0.tgz
cd Python-3.7.0
./configure
make -j 4
make altinstall

Check Python version

Now Python is installed you can check the version using the following command.

python3.7 -V

Make Python 3.7 as the default version

If you want to use python 3.7 as default version you can create an alias.

vim ~/.bashrc

and then add the following alias.

which python3.7
/usr/local/bin/python3.7

alias python='/usr/lcoal/bin/python3.7'

Then source the .bashrc file.

source ~/.bashrc

Check Python Version

After creating an alias check the python version again.

python -V
Python 3.7.0

Now you have successfully installed python 3.7 on Raspberry PI.

 

Leave a Reply

Your email address will not be published.


*