Error: externally-managed-environment

Hi there while following your steps in this youtube video https://youtu.be/iOTWZI4RHA8?si=k2VKTpnPmFgl4Z6I

when I type this command into my pi terminal sudo pip3 install numpy

I get this error.
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.

I follow the fixes but none work please help.

1 Like

This is related to the latest release of the Raspberry Pi OS, Bookworm. And is a decision by the developers of Debian not the Raspberry Pi Corporation. As the error says; you need to create a Virtual Environment. Understanding how this will work can be tricky at first. Anything that is full supported by Debian will not have this problem.

You could simply go back to Bullseye as it does not have this stipulation.

For one of my projects I needed to set up a Virtual Environment, eventually I got it to work. It was getting my head around how it worked. I think Core may have a guide on how to do this, unsure at this time.

Anyway, that is my understanding.

Regards
Jim

EDIT: Some Links.

https://raspberrypi-aa.github.io/session4/venv.html

3 Likes

Hi Jim thank you for the response and the links I will follow those now.

2 Likes