Skip to content
Advertisement

Why python tries to use directly Alsa as a sound output?

I’m using Ubuntu 20.04.5 LTS

When I try to play sound with pygame or pyglet, it plays it normally. However, when my computer is playing sound from any other source, I just get error

Here is the pygame version

JavaScript

I get an error:

JavaScript

It seems that pygame tries to play audio directly from ALSA and that’s why I cannot play multiple sounds

I also tried pyglet

JavaScript

This also works fine, unless there is audio coming from another source. Then I get this error:

JavaScript

Main problem here seems to be that these programs tries to use Alsa directly. I have installed pulseaudio and openal but for some reason it still cannot really use them. I think there is something missing from my system but I have no idea what can it be.

EDIT: I tried to change audiodriver via

JavaScript

But I get an error:

JavaScript

Advertisement

Answer

Well I think I found the solution. Pygame couldn’t connect to other audio device or driver because I used sudo python3 the_file.py instead of python3 the_file.py. Moral of the story: Don’t use sudo on python projects.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement