adafruit / Raspberry-Pi-Installer-Scripts

378 stars 157 forks source link

arcade-bonnet.sh install error on raspberry pi 5 with bookworm "externally managed environment" #313

Open jareddonovan opened 1 month ago

jareddonovan commented 1 month ago

Script Command

sudo bash arcade-bonnet.sh

Operating System

Raspberry Pi OS (64-bit) (debian bookworm) with raspberry pi desktop.

Hardware

Raspberry Pi 5

Behavior

An error occurs when I run the script:

error: externally-managed-environment

Otherwise, the script appears to exit as expected and copies the configuration files to the right places. However, when I reboot the Pi, and test the arcade buttons they do not work.

Description

The full output contains some additional information which may be useful:

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 selected following options when the script first runs:

Otherwise, it is a fresh install of the operating system (from the raspberry PI imager) with no other added libraries or changes.

Other notes:

Additional information

I believe the error arises at line 114. When I comment this line out and run the script, it does not give the error (but obviously still does not work):

pip3 install evdev smbus

I tried several things to fix this. I re-ran the script, rebooted and tested the buttons again after each one, but no luck:

With all these, the libraries appear to install fine, but the buttons still don't work.

jareddonovan commented 1 month ago

Some further debugging notes

I used the journalctl command to look at the logs and found the following:

... rc.local[1411]: Traceback (most recent call last):
... rc.local[1411]:   File "/boot/arcadeBonnet.py", line 92, in <module>
... rc.local[1411]:     gpio.setup(irqPin, gpio.IN, pull_up_down=gpio.PUD_UP)
... rc.local[1411]: RuntimeError: Cannot determine SOC peripheral base address

Line 92, is I believe the second line below from arcadeBonnet.py, which gets installed to /boot by arcade-bonnet.sh

# Enable pullup and callback on MCP23017 IRQ pin
gpio.setup(irqPin, gpio.IN, pull_up_down=gpio.PUD_UP)

Based on that error, it seems that this might be related to some other issues people have reported for GPIO and the raspberry pi 5:

I will take a look at these and see if I can make any progress on a fix.

jareddonovan commented 1 month ago

I think I have solved the issue by uninstalling the python3-rpi.gpio and installing python3-rpi-lgpio in its place, which is supposedly a drop in replacement.

sudo apt autoremove python3-rpi.gpio
sudo apt install python3-rpi-lgpio

I rebooted after this and the buttons and joystick work with an Arcade Bonnet and Raspberry Pi 5.

I'll leave it to the repo maintainer to close the issue in case you want to review and add this fix as a note for readers of the arcade bonnet software installation guide.