Very much a rookie to Pi and python. I've created a python script that reads rfid tags and then plays lights and sounds. The audio comes from a usb sound card, it is a raspberrypi 4. Everything works completely fine running from Thonny, running from the console, even some shell script (I think is what it is) will successfully run my script.
I'm at the stage in my project where I want the script to run automatically when the Pi boots up. I've tried systemd, i've tried crontab, i've tried sudo crontab. Any of those options fail to work and after much googling, i've been able to track down the error, but I don't understand how to resolve

Error: pygame.error: ALSA: Couldn't open audio device: No such file or directory

Update I’ve learned this error happens on my line of code mixer.init() But this line is only erroring when trying to run at bootup from a Cronjob or systemd.

  • Hmm... maybe Thonny has set up environment variable(s)... maybe PATH??
    – Seamus
    Commented Apr 20 at 23:22
  • Here you can see a thread about the error message you are seeing: stackoverflow.com/questions/72042826/…
    – liaifat85
    Commented Apr 21 at 6:35
  • What does PATH mean? Apologies. I did try reading that thread but did not see anything helpful but possible I just do not understand what i am reading
    – JMz
    Commented Apr 21 at 12:45


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.