# Pygame Mixer in python script - No available audio device

**URL:** <https://discourse.nodered.org/t/pygame-mixer-in-python-script-no-available-audio-device/67038>\
**Category:** General\
**Created:** [28 August 2022 18:14 UTC](https://discourse.nodered.org/t/pygame-mixer-in-python-script-no-available-audio-device/67038 "2022-08-28T18:14:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kemperflow](https://avatars.discourse-cdn.com/v4/letter/k/e79b87/32.png) [@kemperflow](https://discourse.nodered.org/u/kemperflow)\
**Post date:** [28 August 2022 18:14 UTC](https://discourse.nodered.org/t/pygame-mixer-in-python-script-no-available-audio-device/67038/1 "2022-08-28T18:14:40Z")

</div>

Using Python3, I am using pygame mixer to play an mp3 using the headphone output. If I run as root or as the dietpi user from the console, the script runs and it plays perfectly. Trying to run the same script from node-red using an "exec" node, I am getting an error that there is No available audio device. I'm assuming the account actually running Node-Red is running the script and it is an access problem. But I am having a hard time finding a thread that relates to this. Thank you!

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [28 August 2022 19:30 UTC](https://discourse.nodered.org/t/pygame-mixer-in-python-script-no-available-audio-device/67038/2 "2022-08-28T19:30:37Z")

</div>

This might help

> [@Exec node can't execute the command but terminal does](https://discourse.nodered.org/t/exec-node-cant-execute-the-command-but-terminal-does/60892/11):
>
> It might not be a file path problem but make sure you've tested that all out 1st When running audio stuff from the exec node - you sometimes have to be explict about specifying what audio hardware to use. I play an mp3 via an exec node and had to add in lots of stuff to get it work mpg123 -a plughw:1,0 alexa.mp3 You might have to do something similar to hear your speech It took a lot of googling to find out how to get mine to work

---

<div class="post-metadata">

**Author:** ![kemperflow](https://avatars.discourse-cdn.com/v4/letter/k/e79b87/32.png) [@kemperflow](https://discourse.nodered.org/u/kemperflow)\
**Post date:** [29 August 2022 13:52 UTC](https://discourse.nodered.org/t/pygame-mixer-in-python-script-no-available-audio-device/67038/3 "2022-08-29T13:52:30Z")

</div>

I did specify the device in the pymixer init, thinking it might be the case, but that didn't work either and it fails on init before I even get to the file path of the music. Instead of pymixer, I will try your mpg123 approach instead, perhaps different libraries will give a different result. I'll post results.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [28 October 2022 13:53 UTC](https://discourse.nodered.org/t/pygame-mixer-in-python-script-no-available-audio-device/67038/4 "2022-10-28T13:53:03Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
