i have a raspberry pi 5, and every time i try to install a new library (using pip) the following message appears
error: externally-managed-environmen×ばつ 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.
can someone help please??
-
What are you ACTUALLY trying to install? Did you read the linked article?Milliways– Milliways2024年06月04日 23:02:42 +00:00Commented Jun 4, 2024 at 23:02
-
You CAN use pip with venv BUT there is often a better way - depending on what you WANT to install, which you haven't stated.Milliways– Milliways2024年06月07日 07:24:06 +00:00Commented Jun 7, 2024 at 7:24
2 Answers 2
Nothing to do with Pi5 - this is an issue with python 3.11 (which is well documented and extensively discussed) which requires pip to use a virtual environment.
Example (setting up in directory cp):-
mkdir cp && cd cp && python -m venv --system-site-packages env
Most python packages are available from the distro package manager and that's the better way to install them if you want them available on the system generally; I think per-user packages have been superceded by the venv restriction mentioned by Milliways.
To search for a python package by name:
> apt search python3 gpiozero
Sorting... Done
Full Text Search... Done
python3-gpiozero/stable 1.6.2-1+b1 armhf
simple interface to everyday GPIO components used with Raspberry Pi (Python 3)
You can then install that w/ sudo apt install python3-gpiozero
.
If the package doesn't show up that way, try:
apt search python3 | grep -C 3 -i gpiozero
grep
is a text matching tool; see man grep
for an explanation of the switches.