Home » Blog » Raspberry Pi » How to install Python on Raspberry pi 4 (Easy Steps)

How to install Python on Raspberry pi 4 (Easy Steps)

Advertisement

How to install Python on Raspberry pi 4 (Easy Steps)

What is Python and how to install it on Raspberry Pi 4?

I hope you all are fit and healthy. As we all know python is one of the most in-demand languages. So I thought why not write something about it. Therefore, in this blog, I am going to tell you how to install Python on Raspberry pi 4.

Python is a high-level, general-purpose, and very popular programming language. The very latest version of python available right now is Python 3.6.4. Python programming language is being used in web development, Machine Learning applications, along with all cutting edge technology in Software Industry. Python Programming Language is very well suited for Beginners, also for experienced programmers with other programming languages like C++ and Java.




Python is the most demanded language in today’s world. It is easy to understand and also follows the concept of Object-Oriented Programming which makes it fit more properly in the world. It is really easy to write and the thing that makes it easy to code is that it has a lot of in-built libraries and functions which makes it easier to code, learn, understand, and more appropriate for users out there.

I would also like to mention some of the features of python which is undoubtedly beneficial to every programmer in the world-

  1. Python is currently the most widely used multi-purpose, high-level programming language.
  2. Python programs generally are smaller than other programming languages like Java. Programmers have to type relatively less and the indentation requirement of the language makes them readable all the time.
  3. Python language is being used by almost all tech-giant companies like – Google, Amazon, Facebook, Instagram, Dropbox, Uber… etc.
  4. The biggest strength of Python is a huge collection of standard library which can be used for the following:
  • Machine Learning
  • GUI Applications (Graphical User Interface)
  • Web frameworks like Django (used by YouTube, Instagram, Dropbox)
  • Image processing (like OpenCV, Pillow)
  • Web scraping (like Scrapy, BeautifulSoup, Selenium)
  • Test frameworks
  • Multimedia
  • Scientific computing
  • Text processing and many more

Now, there are many advantages of python and if I am gonna write them then this whole post would be just covered with this. So I would just mention some of them-

  1. Open Source and Community Development
  2. Easy to learn
  3. Object-Oriented Programming
  4. Portable and Interactive
  5. Portable across Operating systems

Features of Python

 

Not only this python has a lot of connection with our daily life. So I would like to mention some amazing python’s project ideas with you as well-

1. Dice Rolling Simulator

Dice Game

This is a simple roll of the dice program. This program uses the random module in python, where a different value appears at different times.

2. Guess The Number

Guess the Number game

This also uses the random module in python. You can create an input form where the player can input numbers and you can also give them ‘lives’ which increases when they guess correctly and decrease when they don’t.

3. Hang Man-6

hangman6 game

 

This is similar to Guess The Number. The players are given scrabbled letters and they are required to guess a word using those letters.

4. Account Storage

Account Storage

This is a simple interface that allows users to store emails, passwords, and other information. This is not a database but similar to one.

5. Golf Game

Golf Game

 

This uses the Pygame module to create a simple 2D golf game.

So, now let’s learn how to install Python on Raspberry Pi 4

The steps to install Python on Raspberry Pi 4 are as follows-

1. Update the Raspbian

Update the Raspbian before installing python.

sudo apt-get update

2. Prerequisites

Before installing Python 3.8 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 tar wget vim

3. Download Python

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

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

4. Install Python 3.8

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

https://installvirtual.com/how-to-connect-raspberry-pi-to-wifi-without-a-monitor/

5. Check Python version

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

python3.8 -V

6. Make Python 3.8 as the default version

If you want to use python 3.8 as a default version you can create an alias.echo "alias python=/usr/local/bin/python3.8" >> ~/.bashrc

Then source the .bashrc file.

source ~/.bashrc

7. Check Python Version

After creating an alias check the python version again.

python -V
Python 3.8.0

Now you have successfully installed Python 3.8 on Raspberry Pi.

8. Clean up

Now you can clean up using the archive

sudo rm -rf Python-3.8.0.tgz
sudo rm -rf Python-3.8.0

If you have any doubt check the Python installation Guide Video from Below.



How to install Python 3.8 on Raspberry pi – Video Tutorial

Also Read:

Congratulation! You were successful in installing python using Raspberry Pi 4. I hope I have helped you in every possible way. For any kind of doubt don’t hesitate to leave a comment in the comment section.

Similar Posts

2 Comments

  1. I managed all the steps given, including checking the python version which was correct but the python program doesn’t show up in my Raspberry list of “Programming” apps. I rebooted -still nothing. How do I launch python if it is there (which I would like it to be).

Leave a Reply

Your email address will not be published.