Adafruit Speaker Bonnet Setup

Pi 4 - Latest Pi OS

I am trying to install the Speaker Bonnet using adafruit’s doco at Raspberry Pi Setup | Adafruit Speaker Bonnet for Raspberry Pi | Adafruit Learning System.
Running the script calls up ädafruit_shell which is not installed.
In trying to download it I get an error: externally managed environment. This is in the virtual environment.
Running apt install python3-adafruit_shell outside the virtual environment gives me error Could not open lock file…
I have been programming in umpteen languages since 1966 but am a complete newby where Linux is concerned. Help would be appreciated. Geoff

1 Like

Hi Geoff. :slight_smile:

First time in linux as an experienced programmer? How fun! You’ll love it. :slight_smile:

In Linux “could not open lock file” is usually associated with users and permissions.
Linux has different users built in, and they all have different access to files (and in linux. everything is a file).

In Unix/Linux systems the shell has a prepend keyword sudo which translates to “run the following command as if I were, and had the permissions of, another user”.
sudo apt install python3-adafruit_shell # Sudo is kinda like admin in windows
would give you root access, which is access to everything.
I might try that… just to see.

Another option, and probably a more robust option, is to give your user, probably “pi”, permissions to whatever files the package requires. PI OS users a lot of virtual environments for speed reasons.
A package called venv helps with this.

I’ve see this happen to a lot of people recently, seems to be the new version of Raspberry PI OS.
Not you’re fault.

Let me know if any of these ideas work for you. :slight_smile:
Pix :heavy_heart_exclamation:


This is what I finally was able to get going: ( I am not sure what everything does but am starting to get the idea)

Set up a new sd card with Raspberry Pi Imager - Pi OS (64 bit) - Pi 5

gjc@pi:~ $ 
   sudo apt update

   sudo apt full-upgrade


   cd /usr/lib/python3.11


Install the adafruit shell

   sudo pip3 install --upgrade adafruit-python-shell 


gjc@pi:~ $ 
   sudo apt install python3-venv
   python -m venv env --system-site-packages
   source env/bin/activate

(env) gjc@pi:~ $ 
   sudo apt install -y wget
   sudo -E env PATH=$PATH python3 i2samp.python

and we are in business.


Nailed it!

Good find. I reckon this was the secret sauce. :+1:

Reference -


1 Like