Raspberry Pi and Python

From Phidgets Support
Raspberry Pi 4

Introduction

With Phidgets, you can easily extend the functionality of your Raspberry Pi. Follow the steps below to get your first Python program running on your Pi!




Install the Phidget Libraries

If you are using a Raspberry Pi model 2 or above, you can simply enter the following command into the terminal to install the Phidget libraries:

curl -fsSL https://www.phidgets.com/downloads/setup_linux | bash - &&\
apt-get install -y libphidget22

curl -fsSL https://www.phidgets.com/downloads/setup_linux | sudo -E bash - &&\
sudo apt-get install -y libphidget22



Your terminal will look something like this:

Pi install bullseye.jpg



If you are using an older version of the Raspberry Pi, visit our Linux page and view the Source Install instructions.

Install the Phidget Python Module

Now that the libraries (drivers) are installed, the Phidget Python Modules can be installed. You can do this from a specific development environment, like Thonny (bundled with Raspberry Pi OS), or you can install it system-wide through the terminal.

Open the terminal and enter the following command:

pip3 install Phidget22
Install python terminal.jpg


Start by opening Thonny.

Pi thonny 1.png

Thonny defaults to a simple mode on the Raspberry Pi. Click on Switch to regular mode if you have not previously.

Pi thonny 2 2.png

Next, select Tools > Manage Packages.

Pi thonny 3.png

Finally, search for Phidget22 and press Install.

Pi thonny 4 2.png

Run Your Python Program

Now that the Phidget libraries and Python module are installed, you can begin developing against your Phidgets on the Raspberry Pi with Python!