If you are looking for a way to speed up your Python packages installation, you should look into this article. It provides a detailed guideline for speeding up your package’s installation using Raspberry Pi wheels called as Piwheels.
Before going into the detail how Piwheels works on Raspberry Pi let’s first discuss what are Piwheels.
What are Piwheels
Piwheel is a pre-built binary package management system for Raspberry Pi that distributes a pre-built version of packages and saves the users from rebuilding the packages themselves. It allows a faster and more stable package distribution system making it a better way to save your time in the package’s installation.
How it work on Raspberry Pi
The Raspberry Pi users widely use the command-line terminal to install different packages on their device and they certainly use the pip installer to download different Python packages. The speed of the pip installer is fine while installing packages implemented in Python language, but if these are written in C language, the installation will take a lot of time in rebuilding the source. Thus, you will certainly need to acquire the Piwheels services to download Python packages quickly.
For the latest version of Raspberry Pi OS, wheels are already installed and if you are using an older model of Raspberry Pi then you will need to run the following command to successfully install the wheels on your device.
As in our case, it is installed on our Raspberry Pi device.
Once you ensure that the wheel is installed, you can then move on and try to install a package. Here, we are installing a package with the name Scipy which is generally used for mathematical and scientific computing.
Here, as an example we will install Scipy using the pip3 installer using the below given command:
As you can see from the above installation process, the pip3 installer will be directed towards the Piwheels website and it will download the file which is well compatible with your Python version.
It then picks the Scipy wheel file with “.whl” format and compiles it on the terminal.
It also downloads the necessary package “numpy” to run the Scipy on your Raspberry Pi device. The numpy would be necessary as it’s a fundamental package to perform different computational tasks in Python.
In our case numpy is already installed so it skips the step and then provides you with the output that both numpy and scipy are successfully installed on your device.
In this way, you can install multiple Python packages through a pip installer within a few seconds as Piwheels will quickly do the process for you and you don’t have to build any package by yourself.
In another scenario, if you install Scipy using pip installer, it starts downloading the “tar.gz” file which you have to build it by yourself and it can take a long time to do so or it may require some dependencies to install it on your device.
If pip won’t find a source distribution, the process will fail to install Scipy on your Raspberry Pi device and you will encounter an error as shown below.
Hence, installing Python packages from the pip3 installer will be an effective approach as it uses the Piwheels to speed up the installation process.
The Raspberry Pi device needs different Python packages to perform various computational tasks. With the help of Piwheels, it is now possible to download Python packages much faster. If you want to save time installing different Python packages on your Raspberry Pi device, you should choose the pip3 installation that performs the installation through Piwheels.