World Tech

How to Install and Use Python Packages on Raspberry Pi? –

This is a simple tutorial for installing Python packages on Raspberry Pi. It is made to be simple and easy to understand. You will learn how to install and use a few Python packages that you can use in your projects.

Python is a powerful programming language that has been built for versatility and ease of use. You can write, compile and run Python programs on a wide variety of platforms, from embedded devices to desktop computers, and even create 3D games with it. Python can also be used on a Raspberry Pi, a popular single-board computer that is a great introduction to programming. In this tutorial, we will show you how to install and use Python packages on a Raspberry Pi.

Python is already installed on the Raspberry Pi, but to use it to create scripts and build various projects, it often requires some dependencies called libraries or modules. Even if you know Python well, you may need help installing new packages for Python on your Raspberry Pi, which is why I wrote this article.

Most Python packages for Raspberry Pi are available in the apt repositories. Searching for the name of the library with this tool is the fastest way to install it. Another tool, called PIP, can also be used for some other modules not included in the standard repositories.

Anyway, I will explain everything in this article. I’ll start with APT, because most modules can be installed with it, then I’ll introduce PIP, and I’ll finish with some tips on managing Python libraries.

Installing Python packages on your Raspberry Pi

The easiest way to install new Python packages is to use APT (or its graphical version : Add/Remove Software). The most common Python libraries will be available in the repositories, often with names like python3-library.

Find Python packages on your Raspberry Pi

A Python package is created to have reusable code on hand in every project. For example, the Python library can help you with mathematical functions, interaction with the API or a particular accessory. If you use such a module, you don’t have to program the same functions in every new project.

If you’re working on larger projects, you can create your own Python libraries, but mostly it’s just a matter of downloading and installing the packages available in the Raspberry Pi operating system repositories.

I will explain how to do this using the Add/Remove Software tool or directly from the apt command line, but the first thing you need to know is the name of the package you need to install.

Raspberry Pi Bootcamp
sale: 10% off today.
Take it to the next level.
I’m here to help you get started with your Raspberry Pi.
Learn all the necessary skills in the right order.

Recommended Python libraries on the Raspberry Pi

The following section works well if you have a particular Python module you’re interested in (and it’s available in the repositories), but maybe you’re just looking for ideas and don’t know which packages to install.

First of all, I recommend you to read this article, which presents 15 cool Python project ideas for the Raspberry Pi. It’s always better to start with a set goal and build on that than to try something without a clear goal.

Next, here are some interesting Python libraries that you can use with the method described below:

  • I did it with emotion: This is the most popular HAT for the Raspberry Pi, and there is a great module for it. If you are interested, you can read my tutorial here.
  • Mistletoe Zero: The example I will discuss in the next section is a simple way to create a basic user interface in Python (forms, buttons, etc).
  • Minecraft Pi: Minecraft is preinstalled on the Raspberry Pi. This is a special version that comes with a Python library for interacting with the game, which is a great way to learn Python, especially for kids. I have a manual here too.
  • OpenCV : Looking for something more advanced? OpenCV is a computer vision library that allows you to experiment with machine learning.

Installing new Python packages on your Raspberry Pi

  • On the Raspberry Pi operating system, use the desktop to open the Add/Remove Software tool.
  • In the search engine, enter the name of the library you are looking for.
    Let’s take the example of the word guizero.
  • The tool shows you the corresponding packages:

  • Check the appropriate box and click Apply to install it on your system.
  • In a few seconds, the package is installed and ready to be used in Python.

Message: At this point, Python 2 and 3 are installed on the Raspberry Pi. Make sure you install the packages that match the version you are using in your script. Read this article if you’re not sure.

If you don’t have a desktop environment or prefer to use the command line, here’s the equivalent with :

  • In the terminal, type the following command to find the exact name of the package:
    apt search guizero
  • Then install the correct package:
    sudo apt install python3-guizero

Using PIP on the Raspberry Pi

While the most common Python libraries are available in the repositories of the Raspberry Pi operating system, there are many others that cannot be installed this way. Most developers use other methods to share their libraries with the world: PIP.

What is PIP on the Raspberry Pi?

PIP is a package manager for Python packages. It comes pre-installed on the Raspberry Pi operating system and allows you to install libraries that are not available in the standard repositories.

It is a kind of secondary repository where it is easier to download and share a Python library. Most developers use it to support their code. It is also easy to use for the end user (you!), as installing PIP packages is no more complicated than using apt.

You can access the web portal for this tool here and use the search engine to find a Python library to install on your Raspberry Pi. I will explain everything in the following paragraphs.

Installing PIP on the Raspberry Pi

PIP is already installed by default on the Raspberry Pi operating system. If you are using a different operating system or have uninstalled it, you can install it as follows:
sudo apt install python3-pip

As for any Python package, there are two packages available in the repository : python-pip and python3-pip. Make sure you have installed and are using the correct version for your Python installation.

Master your Raspberry Pi in 30 days
Sale: 10% off today. Download
Unlock the secrets of the Raspberry Pi in 30 days.
Learn useful Linux skills and practice some projects.

Installing Python packages with PIP on your Raspberry Pi

There is a search command in PIP, but it no longer seems to be available (PyPI’s XMLRPC API is currently disabled due to an unmanageable workload and will be abolished in the near future), so the best way to find package names is to use the website :

  • Let’s say you’re looking for a Python library to use the Twitter API.
  • Go to and search on Twitter:

  • Then review the results to find a solution that works for you. Results can be sorted by relevance, trends and last update.
    Try to avoid libraries that are no longer updated, especially in this case.
  • On the library’s page, you will usually find documentation and the command to install the package.
    For example :
    pip install python-twitter
    On the Raspberry Pi, you need to use sudo and also pip3 to run the script with Python 3 :
    sudo pip3 install python-twitter

If there are required dependencies, pip will automatically install them on your Raspberry Pi.In this example, the packages future, requests, and requests-oauthlib are installed automatically because they are required by python-twitter.

Where do PIP packages go after installation?

After downloading and installing, PIP packages are stored in /usr/lib/python3/dist-packages. The show command shows the exact location of each package: for example pip3 show requests.

In the next section, I present some other commands you can use to get a better idea of what is installed on your Raspberry Pi.

Using Python packages on your Raspberry Pi

List of Python libraries installed on the Raspberry Pi

There are several ways to install Python packages, as well as a list of packages already installed on the Raspberry Pi. A more complete way is to use help(modules) in the console or the graphical equivalent with Thonny.

List of Python modules in the console

  • Open the Python console with:
  • Enter the help command to display all available modules:

This may take some time, depending on the number of packages installed, and may show some errors and various debugging information, but you should get a complete list.


Thonny is the default Python text editor on the Raspberry Pi desktop operating system. If you are using this version, there is a hidden function with a list of available Python modules:

  • From the main menu, open the Thonny Python IDE via the Programming submenu.
  • Click Switch to normal mode if you are in basic mode and reboot.
  • A menu will appear at the top, click on Tools > Manage packages.
  • A window similar to the following appears:

  • You will receive the same information as in the previous method, but in a more user-friendly form.

By the way, I didn’t explain this method in the previous article, but you can also install PIP packages directly in Thonny. Use the search engine above and click Install to add new Python modules to the list.

List of packages installed through PIP

There is a command in PIP to list all installed packages, here is
pip3 list

You will get a list of all installed packages and their version. It will be much faster, but I’m not sure it really covers everything (like those without PIP installed).

List of installed Debianpackages

A final option is to check the installed packages, for example. B. with apt:
sudo dpkg -l | grep python3-

You can use this command on a recent installation to see what is already in your system.

Importing the Python library into a script

After the Python library is installed using apt, PIP, or some other method, it can be imported into the source code by adding this line to the beginning of the script:
For example:
Importing applications

Then follow the appropriate documentation to take advantage of all the new features this module offers.
My example is a library for creating HTTP requests in Python, with simple code like this:
import requests
r = requests.get(‘’)
Much easier than doing everything yourself from scratch.

Python libraries are very powerful. So before you spend hours creating your own features, check if there isn’t something already out there that can help you.

Getting started with Python on your Raspberry Pi

By the way, if you need help learning Python, you can read the Python for Beginners tutorial here and check out my new ebook Master Python Programming on Raspberry Pi in the store.

Python is an essential skill to learn if you want to start new projects on your Raspberry Pi. The best projects often require Python code to automate the process. For example, most Raspberry Pi robotics kits are programmed in Python.

Raspberry Pi resources

Don’t know where to start?
Understand everything about the Raspberry Pi, stop constantly looking for help and finally have fun with your projects.
Check out the Raspberry Pi Bootcamp course now.

Learn the Raspberry Pi in 30 days
Want to learn more than the basics? If you are looking for the best tips on how to become a Raspberry Pi expert, this is the book for you. Learn useful Linux skills and put various projects into practice with step-by-step tutorials. Download the e-book

VIP Community
If you just want to communicate with me and show your support, you can also join the Patreon community. I share behind-the-scenes information and give you early access to my materials. You will also receive an encouraging message when you sign up.
More information here

On this page you will also find all my recommendations for tools and equipment.

Frequently Asked Questions

How do I install Python packages on Raspberry Pi?

The easiest way to install a package is to use pip. pip install package_name If you don’t have pip installed, you can use easy_install. easy_install package_name If you want to install from the source, you can use the following command: python install How do I uninstall a package? To uninstall a package, you can use the following command: pip uninstall package_name To uninstall from the source, you can use the following command: python uninstall package_name

How do I manually install a python package?

To install a python package, you will need to use pip. To install a package with pip: pip install package To uninstall a package with pip: pip uninstall package To update a package with pip: pip install –upgrade package

How do I install pip on Raspberry Pi?

sudo apt-get install python-pip How do I install pip on Windows? You can download the installer from here.

Related Tags:

Feedback,raspberry pi pip installinstall python 3.5 raspberry piraspberry pi manually install packagesraspberry pi pip command not foundinstall python 3.6 raspberry piinstall python 3.7 raspberry pi,People also search for,Privacy settings,How Search works,raspberry pi pip install,install python 3.5 raspberry pi,raspberry pi manually install packages,raspberry pi pip command not found,install python 3.6 raspberry pi,install python 3.7 raspberry pi,install python 3 on raspberry pi,raspberry pi install python 3 command line

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *