Servo motors on Sparkfun pHAT with Raspberry PI 5

Hello,can you help?
I’m trying to control servo motors for the Mearm Robotic Arm using Sparkfun servo pHAT on a RP5.

When I type the following in terminal I get the following error message.  I am new to this and have no idea what is happening.

Best wishes,  John.

sudo pip3 install sparkfun-qwiic

john@raspberrypi:~ $ sudo pip3 install sparkfun-qwiic

error: externally-managed-environment

× This environment is externally managed

╰─> To install Python packages system-wide, try apt install

python3-xyz, where xyz is the package you are trying to

install.

If you wish to install a non-Debian-packaged Python package,

create a virtual environment using python3 -m venv path/to/venv.

Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make

sure you have python3-full installed.

For more information visit http://rptl.io/venv

note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.

hint: See PEP 668 for the detailed specification.

The Pi OS has a package manager (apt), this error lets you know that installing via pip might create conflicts with its python packages. The usual recommendation is to use a ‘virtual environment’ to isolate external packages, I’d recommend watching 2-3 videos on how virtual environments in python work before implementing one so you don’t get confused/lost. Then, use the commands below this to keep & interact with your project isolated from the system’s Python:

# Create a virtual environment
python3 -m venv ~/myenv

# Activate it
source ~/myenv/bin/activate

# Install packages (no sudo needed!)
pip install sparkfun-qwiic

# Deactivate when done
deactivate

To use it again later, just run source ~/myenv/bin/activate.

Thanks for your response. I’ll take your advice and watch some videos then use the commands you gave. Its all really a different language to me so I’m expecting a steep learning curve and hours of trying to understand what I’m doing.
Again, thank you.

1 Like