1

I am attempting to use Sounds with my Python Pygame Game and it threw me this error:

Traceback (most recent call last):
  File "main.py", line 5, in <module>
    pygame.mixer.init()
pygame.error: No available audio device

How would I go about fixing this?

*Thanks in advance for the help!

Anthony
  • 23
  • 1
  • 7
  • 1
    Does this answer your question? [pygame projects won't run: "pygame.error: No available video device"](https://stackoverflow.com/questions/32533585/pygame-projects-wont-run-pygame-error-no-available-video-device) – MedoAlmasry May 03 '20 at 21:38

2 Answers2

0

Playing audio does not work on Repl.IT as the Code is run on a Server, which has no connection to the speakers of your Computer.

This is the Output, when i reproduce your error:

pygame 1.9.6
Hello from the pygame community. https://www.pygame.org/contribute.html
ALSA lib confmisc.c:767:(parse_card) cannot find card '0' <--- ALSA can not find the card
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM default
ALSA lib confmisc.c:767:(parse_card) cannot find card '0' <--- ALSA can still not find it
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM default
Traceback (most recent call last):
   File "main.py", line 3, in <module>
      pygame.mixer.init()
pygame.error: No available audio device
exit status 1

See https://repl.it/talk/ask/Pygame-Audio-Issues/12147.

Twistios_Player
  • 120
  • 3
  • 11
0

I am assuming you're working in a Linux environment, as such, I would suggest you install the following prerequisite libraries:-

libSDL-1_2

libSDL_devel

libSDL_image-1_2

libSDL_mixer-1_2

libSDL_ttf-2

In ubuntu you could make use of the following line

sudo apt-get install libsdl1.2-dev libsdl-image1.2 libsdl-mixer1.2 libsdl-ttf2.0
MedoAlmasry
  • 452
  • 5
  • 19