Search code examples
pythonpygamemixer

Mixer module won't initiate


I've been trying to get into pygame, and I want to play a sound. I try to initiate the mixer module like this:

import pygame
import time
pygame.init()
pygame.mixer.init()

When I run it, it gives this error:

Traceback (moce recent call last):
    File "main.py", line 5 in <module>
        pygame.mixer.init()
pygame.error: ALSA: Couldn't open audio device: No such file or directory

I am running the code on repl.it, and I'm unsure if its repl's issue, as it has caused issues on code that ran perfectly on the default IDLE.


Solution

  • pygame.mixer won't work on repl.it as it doesn't have an audio device associated with it
    as you said it works on IDLE. It is because your device has an audio device