Pianohat

Hi,
i have a question relating to piano hat. I 've just put a new rpi installation with the newest jessie. Put piano hat, enabled i2c, but every time I try to run simple-piano.py I get an error:
This script requires the pygame module
Install with: sudo pip install pygame

When I try to install pygame I got :
Looking in indexes: Simple index, piwheels - Simple index
Requirement already satisfied: pygame in /usr/lib/python3/dist-packages (1.9.6)

so I have pygame for python3… but still cannot run piano hat… can You help me ?

Regards,
mike

You could try running the example with python3 simple-piano.py to specify that you want to use Python 3? I suspect you might run into other problems using an OS as old as Jessie though.

Thanks,

should I change Jessie ? what’s your recommendations ?

Regards,
Mike

an yeah… I have other error now:

s/simple-piano.py:38: RuntimeWarning: use mixer: libSDL2_mixer-2.0.so.0: cannot open shared object file: No such file or directory
(ImportError: libSDL2_mixer-2.0.so.0: cannot open shared object file: No such file or directory)
pygame.mixer.pre_init(44100, -16, 1, 512)
Traceback (most recent call last):
File “/home/michalboryka/Pimoroni/pianohat/examples/simple-piano.py”, line 38, in
pygame.mixer.pre_init(44100, -16, 1, 512)
File “/home/michalboryka/.local/lib/python3.9/site-packages/pygame/init.py”, line 70, in getattr
raise NotImplementedError(missing_msg)
NotImplementedError: mixer module not available (ImportError: libSDL2_mixer-2.0.so.0: cannot open shared object file: No such file or directory)

You can download and flash the most recent Raspberry Pi OS image using Raspberry Pi Imager:

will do. Shouldd it help with missing mixer lib libSDL2_mixer-2.0.so.0?

regards
mike

Running an up to date OS may well sort your missing dependencies, but I found this post that contains some things you could also try: python - Pygame: ImportError: libSDL_ttf-2.0.so.0: cannot open shared object file: No such file or directory - Stack Overflow