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.
What is Python and how to install it 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-
- Python is currently the most widely used multi-purpose, high-level programming language.
- 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.
- Python language is being used by almost all tech-giant companies like – Google, Amazon, Facebook, Instagram, Dropbox, Uber… etc.
- 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
- 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-
- Open Source and Community Development
- Easy to learn
- Object-Oriented Programming
- Portable and Interactive
- Portable across Operating systems
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
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
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
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
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
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
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.
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
5. Check Python version
Now Python is installed you can check the version using the following command.
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.
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
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.