Pygame.error: mixer not initialized

Question:

Repl link:

code snippet

Hi, Im using tkinter and pygame, but then it appear this error:

Traceback (most recent call last):
  File "/nix/store/xf54733x4chbawkh1qvy9i1i4mlscy1c-python3-3.10.11/lib/python3.10/tkinter/__init__.py", line 1921, in __call__
    return self.func(*args)
  File "/home/runner/a/main.py", line 10, in reproducir_cancion
    pygame.mixer.music.load("Everything Black.mp3")
pygame.error: mixer not initialized

here is the lin: https://replit.com/@pipelopezr2009/Taller-Punto-1#main.py

@pipelopezr2009 I’m not seeing any error when I load the repl on my end…

1 Like

but do uoy know why this error appears to me?

No. I do not. Are you looking in the shell, console or output tab?

1 Like

I mean, do you hear the music?. It is suppose that when you press the image of the song, it sounds

audio with Replit is pretty unreliable. anyway call pygame.mixer.init() before using the mixer

1 Like

I did it, but now it appears:
Exception in Tkinter callback

Traceback (most recent call last):
  File "/nix/store/xf54733x4chbawkh1qvy9i1i4mlscy1c-python3-3.10.11/lib/python3.10/tkinter/__init__.py", line 1921, in __call__
    return self.func(*args)
  File "/home/runner/Taller-Punto-1/main.py", line 16, in e
    pygame.mixer.init()
pygame.error: dsp: No such audio device

yep that’s what I was talkin about

there’s a replit audio module

So there is nothing we can do to make sound the music, yes?

no, I literally told you an alternative

ok, thank you very much for your help

please mark the post that helped you most as the solution

but sorry, i didn’t understand how to make the music sound

https://docs.replit.com/tutorials/python/audio

you might be able to use pygame audio by inserting this into the .replit file:

audio = true

then click the headphones button before running repl
no guarantees that it’ll work though

1 Like

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