Projects
Using pip on Raspberry Pi
Learn about installing Python software on your
Pi with pip
Step 1 What you will make
Find out how to use pip on a Raspberry Pi to easily install useful Python software.
What you will learn
By following this guide, you will learn:
What is pip?
How to use pip to install Python packages on Raspbian
Step 2 What you will need
Hardware
Raspberry Pi running Raspbian
Step 3 What is pip?
If you have used Python before, you may have used code similar to this:
from time import sleep
Or perhaps this:
import random
In the examples above, you are importing a module in order to use code written by somebody else. The
modules in the examples are called time and random, and are included by default when you install Python.
However, people have written lots of other Python modules, and you might want to use some of their functions
in your Python programs. For example, if you want to manipulate images you might want to use PIL, or you
could make games with pygame, or craft GUIs with guizero. However, if you try to use these modules without
installing them, they won’t work:
This is where pip comes in. To be able to use use external Python modules in your programs, you can use the pip
tool to install them on your computer. (You have probably already seen instructions for installing Python
modules with pip in guides on the Raspberry Pi website and on other websites.)
A Raspberry Pi with the standard version of Raspbian will have pip already installed.
Step 4 Upgrading pip
If you’re using an older version of Raspbian, the version of pip installed might out of date, which can cause
problems. Therefore, it’s a good idea to keep your software up to date.
To upgrade all the software on your Raspberry Pi, including pip:
Open a terminal window by clicking Menu > Accessories > Terminal.
open a terminal
Type in the following commands to update and upgrade Raspbian.
sudo apt-get update
sudo apt-get upgrade
Step 5 Using pip
There are two versions of pip installed on the Raspberry Pi:
1. pip for installing Python 2 modules
2. pip3 for Python 3 modules
Under normal circumstances, you should only be using Python 3 and therefore pip3.
You can install modules using the pip3 install command. For example, if you wanted to download the
guizero module, you would type this into a terminal window:
sudo pip3 install guizero
Other pip commands
There is comprehensive documentation for pip at [Link] ([Link] — here are a few useful
commands:
Upgrade an already installed module:
sudo pip3 install --upgrade name_of_module
Uninstall a module:
sudo pip3 uninstall name_of_module
List all installed modules:
sudo pip3 list
Published by Raspberry Pi Foundation ([Link] under a Creative Commons
license ([Link]
View project & license on GitHub ([Link]
Published by Raspberry Pi Foundation ([Link] under a Creative
Commons license ([Link]
View project & license on GitHub ([Link]
-on-raspberry-pi)
Accessibility ([Link]
Cookies Policy ([Link]
Privacy Policy ([Link]
Translate for us (/en/projects/translating-for-raspberry-pi)