So, I'm working on a little project for myself, using pygame and tkinter to build an mp3 player.
Everything works when running the program using visual studio, but when I turned the program to an .exe file using pyinstaller and tried to run in, the following appeared:pygame.mixer.load(song)
pygame.error
Failed to execute script
I've tried everything, but it keeps telling me the same. Here you can see how I call the song:
pygame.init()
pygame.mixer.init()
song = path + '\music\\' + selected_song
pygame.mixer.music.load(song)
Being path + '\music\\'
, the directory where the songs are. And slected_song
the name of the song + '.mp3'
.
os.path.join(path, "music", selected_song)
- furaspyinstaller
may have problem to find all modules and C/C++ libraries needed to work and you may have to add them manually - for example PyGame depends on C/C++ librarySDL
. Search more info on PyInstaller page - ie. in FAQ. BTW: If you don't get more error message then you could useprint()
to see values in variables. Maybe yourpath
is not correct and it has problem to load it. System may run it in different folder then you expect and thenpath
may be incorrect - especially if it is relative path. - furas