So I'm trying to convert tkinter file into executable using pyinstaller. I've done it with picture, but when I create executable that contains some sort of audio it says "Failed to execute script playmusic" (playmusic is the script name). I've tried changing the script name, using .wav song, replacing the exe from the dist folder to the script directory together with the song but none of this worked. I've also tried with auto-py-to-exe, but it doesn't work. The song is played with pygame, and works without any issue inside VS Code. It doesn't matter if I am using pyinstaller or some other module. I'm using python 3.8.2 on Windows 10.
This is the python script:
import tkinter as tk
from pygame import mixer, time
root = tk.Tk()
root.title("Music Player")
root.geometry("300x100+800+100")
label1=tk.Label(root, text="Start Song: ", fg='green', anchor="w")
label1.grid(row=0, column=0)
file = 'Ignite.mp3'
mixer.init()
mixer.music.load(file)
play = lambda: mixer.music.play()
button1 = tk.Button(root, text = 'Play', command = play)
while mixer.music.get_busy(): time.Clock().tick(10)
button1.grid(row=0, column=2)
pause = lambda: mixer.music.pause()
button2 = tk.Button(root, text="Pause", command = pause)
button2.grid(row=0, column=3)
resume = lambda: mixer.music.unpause()
button3 = tk.Button(root, text="Resume", command = resume)
button3.grid(row=0, column=4)
stop = lambda: mixer.music.stop()
button4 = tk.Button(root, text="Stop", command=stop)
button4.grid(row=0, column=5)
root.mainloop()
It's kind of a music player. The pyinstaller code I run to execute the script is the following:
pyinstaller --add-data "Ignite.mp3;." --onefile -w playmusic.py
It executes without problem, but when I run the executed script, in a pop-up window it says "Failed to execute script playmusic"