raspberrypipress / official-raspberry-pi-beginners-guide-5e

Code and resources for The Official Raspberry Pi Beginner's Guide, 5th Edition from Raspberry Pi Press
35 stars 6 forks source link

[Errata]: Sense Hat Emulator does not work under Bookworm #1

Open bjepson opened 9 months ago

bjepson commented 9 months ago

Contact Details

brian.jepson@raspberrypi.com

What format of the book has this error? You may select more than one option.

Print, PDF, ePub

What language of the book has this error?

English (EN)

Page Number or Section

Chapter 7

Detailed description

At the time of publication, the Sense Hat Emulator did not work under the newest, Debian Bookworm-based version of Raspberry Pi OS. Scratch 3 did not support Raspberry Pi 5 at the time of publication, either.

However, you can install a version of the Sense Hat Emulator, along with a version of Thonny that can talk to the emulator, with these commands:

sudo apt install libgirepository1.0-dev gcc libcairo2-dev pkg-config python3-dev gir1.2-gtk-4.0 libopenblas-dev
python3 -m venv ~/sense-emu-env
source ~/sense-emu-env/bin/activate
pip3 install pycairo PyGObject sense-emu thonny

Whenever you want to run the Sense Hat Emulator, you'll need to open a Terminal, run . ~/sense-emu-env/bin/activate, then run the Sense Hat Emulator with sense_emu_gui. If you want to use Thonny with the Sense Hat Emulator, you need to run thonny from the terminal after you run the activate command.

You may also find that some Sense Hat Emulator sensors, such as humidity, do not work under 64-bit Bookworm-based Raspberry Pi OS, but will work under the 32-bit version.

A future update to Raspberry Pi OS will eliminate the need for this workaround.

You can more information on virtual environments and why they are required at https://rptl.io/venv