sudo pip3 install st7789 gets me an “Externally Managed Environment” error message and won’t do the install.
Raspberry Pi 400 running the latest official 64 bit Desktop version (bookworm).
From Bookworm the way Python modules are installed is changing:
From Bookworm onwards packages installed via
pipmust be installed into a Python Virtal Environment using
venv. This has been introduced by the Python community not Raspberry Pi, see PEP 668 for more details
If you check out the Python Section of the Pi OS Documentation they explain how to use virtual environments.
Thanks Shoe, for the link.
After looking at that virtual environment stuff ,my head hurts. =(
It looks like Jeff Geerling has a simple way to restore the old behaviour : How to solve "error: externally-managed-environment" when installing via pip3 | Jeff Geerling
I can understand the change, I’ve fallen foul of python systems fighting each other, but it’s a bit of a hassle for simple stuff.
I couldn’t have said it better.
That second link looks interesting, I “will be” looking at that latter on today.
Only just got up, haven’t even finished my first cup of java.
Thanks Shoe. :)
@alphanumeric: don’t do it. Don’t shoot yourself in the foot. It does not make sense to work against mainstream. These quick-wins will hurt you later. You will run into problems and you won’t remember that one day way in the past you deleted some magic file (which by the way will probably come back with the next update anyhow).
One day or the other, you will have to adopt to how the world now works.
Thanks for the warning, I do apricate that you did that. I may do it anyway just to see what happens. I’ve only just did the install and the usual minimal config done. Not a big deal if I muck it up.
On the topic of may come back to haunt me, I’ve already had to do a rpi-update on two of my Pi setups to get the touch working on the Official 7 inch Touch screen.
Really? An in house product that doesn’t fully work on launch day of a new build?
This is nothing new. When the CM4IO-board came out, the RTC of that board was not supported in the kernel at all. And even now, years after launch, the kernel still does not support wake on rtc-alarm, although the CM4IO-board has all the necessary circuitry for that. The Pi hardware team does not seem to communicate well with the Pi software team.
I hear you, I was really hoping USB HID would be an option in the latest Micro Python release. =(
Although, I think this is a third team?
Exactly. MicroPython is an independent project. But it is openly developed, so the Pi-Foundation could contribute.
I haven’t decided which way I’m going to go? I will likely try the official way first, just to see if its as much of a PITA as I think it will be. And go to plan B if I get pissed off enough.
I will post what I do, when I find my round 2it. ;)
Let me know if you need help. I think it is simple: only two steps, one to create the virtual environment, one to activate it. After that, everything is as always:
cd to_the_project_folder python3 -m venv runtime source runtime/bin/activate pip3 install package1 package2 ...
That is the installation. To use the virtual environment, you use
cd to_the_project_folder source runtime/bin/activate
or even simpler
Think of me what you will, but I bailed and went Legacy OS. :p
I re flashed my SD Card with the 64 bit Legacy option. It’s my Pi 400, so it was a viable option. The st7789, RV3028 RTC, and trackball breakout software all installed without having to jump through hoops.
With my wife still in hospital, I’ve been a bit stressed lately. Which isn’t helping my chronic pian issues any. I just wasn’t in the mood to mess with it, potentially 3 times.
As I said in the other thread, Bullseye is a good choice. It will be supported by Debian until the successor to Bookworm arrives. By then, the installers should be updated and you won’t have any problems.
I usually only update to new OS-versions when necessary. Old projects that are running fine don’t need updates, especially if they don’t connect to the Internet or only use very specific URLs.
Ditto to that, especially if its a bit of a pain to set them all back up again. I have a couple of very simple basic setups that are good candidates for a new OS release. More often that not anyway.
I have some others, like my Pirate Radio, that just work, and haven’t been messed with for years.
I’ve been using Pimoroni’s Blinkt product for years on most versions of Raspbian, up until Buster.
I’ve just encountered the ‘Externally Managed Environment’ problem when installing Blnkt on a PIZ 2 64-bit Bookworm lite, using Pimoroni’s recommended installer:
curl https://get.pimoroni.com/blinkt | bash
I’ve looked at this bash script and it’s quite complex, being designed for installing various Pimoroni products including Blinkt. I’ve followed Jeff Geerling’s workaround and managed to get Blinkt working on Bookworm using Pimoroni’s script. However, I would like to use the recommended virtual environment solution, but need to simplify Pimoroni’s script so that it applies only to Blinkt installation.
Please can Pimoroni give some advice on the minimum number of bash commands needed to install Blinkt on a new rpi-imager Bookworm 64-bit lite installation, so that a virtual environment install can be done ?
I think our @gadgetoid was working on an update to the Blinkt! installer last week…
Eventually managed to solve this blinkt library install problem by creating a virtual environment, and making a small change to line 836 of Pimoroni’s installer script, to include an absolute path to my virtual environment my_venv at the point where pip gets installed:
if ! sudo -H ~/my_venv/bin/$PIP3_BIN install --upgrade “$piplibname”; then
This change allows the script to run to conclusion without giving the ‘externally-managed-environment’ error.
I found the following guide a great help in understanding python virtual environments: