nordvpn

Install Python 3.6 on Raspberry PI CLI

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

Requirement

  • Raspbian Stretch should be installed

.                       

Step 1. Update the Raspbian

Update the Raspbian before installing python.

sudo apt-get update

Read Also: How to install python 3.7 on Raspberry

Step 2. Prerequisites

Before installing python 3.6 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

Step3. Download Python 3.6

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

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

Step4: Install Python 3.6 on Python

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

Step 5. Check Python version

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

python3.6 -V

Step 6. Make Python 3.6 as the default version

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

vim ~/.bashrc

and then add the following alias.

which python3.6
/usr/local/bin/python3.6

alias python='/usr/local/bin/python3.6'

Then source the .bashrc file.

source ~/.bashrc

Step 7. Check Python Version

After creating an alias check the python version again.

python -V
Python 3.6.8

Now you have successfully installed python 3.6 on Raspberry PI.

4 Comments Posted

  1. Thanks for the awesome guide! I have tried many tutorials on the internet for installing python 3.6 but didn’t help. But this one really helped!
    (Sorry for my poor English. English is not my first language!)

  2. Very nice. Thankyou.

    Question about the default setting… The ~/bashrc script you described had the unexpected effect of launching python 3.6 as soon as I log in. Accordingly to set the default I simply ran the command:
    $ alias python=’/usr/local/bin/python3.6′ and that was all that was needed so that: $ python -V would return the correct version number.

  3. Brilliant guide! Just blindly copied everything in your post and it worked like a spell! Thank you so much Kapoor sahab!

Leave a Reply

Your email address will not be published.


*



The reCAPTCHA verification period has expired. Please reload the page.

48-Hour Flash Sale! Courses from just $10.99