'Kivy to Exe with PyInstaller. [Failed to execute script main] because of SoundLoader

Im trying to convert my .py file to .exe. Im using kivy in my .py file.I realized that getting Fatal error detected.Failed to execute script main error if i use SoundLoader.load('test.wav'). main.py :

from kivy.app import App
from kivy.core.audio import SoundLoader
from kivy.uix.screenmanager import ScreenManager
class Manager(ScreenManager):
    sound = SoundLoader.load('test.wav')
    sound.play()
class testapp(App):
    def build(self):
        return Manager()
if __name__ == '__main__':
    testapp().run()

If i run my .py file,i get sound on windows and linux systems.I followed these steps to create my exe: KIVY package for Windows. My exe runs if i do not use SoundLoader lines. But if i add that , i can't even open console or app because this error appears.Thanks for advices.



Solution 1:[1]

If you have same problem , Fix this lines in your .spec file:

from kivy_deps import sdl2, glew, gstreamer
...
...
datas=[('Files\test.wav','.')
...
...
*[Tree(p) for p in (sdl2.dep_bins + glew.dep_bins +  gstreamer.dep_bins)],
...
...

Worked for me..

Solution 2:[2]

This worked for me.

from kivy_deps import sdl2, glew, gstreamer

datas=[(r'Assets', 'bullet.wav'),
         (r'Assets', 'music.wav'),
         (r'Assets', 'Explosion.wav')],

*[Tree(p) for p in
           (sdl2.dep_bins +
           glew.dep_bins +  gstreamer.dep_bins)],

Solution 3:[3]

The next thing helped me:

python -m pip install kivy[full]

This overlaped prior conda installation:

conda install -c conda-forge kivy

After that mp3 file played fine.

Packages alteration after installation from pip (my dir):

kivy-deps.glew~=0.3.1 in f:\pzz\lib\site-packages (from kivy[full]) (0.3.1)

kivy-deps.gstreamer~=0.3.3 in f:\pzz\lib\site-packages (from kivy[full]) (0.3.3)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 User981273891279
Solution 2 Muhammed Kahraman
Solution 3