简体   繁体   English

Kivy 使用 PyInstaller 执行。 [Failed to execute script main] 因为 SoundLoader

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

Im trying to convert my.py file to.exe.我正在尝试将 my.py 文件转换为 .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') .我在 my.py 文件中使用 kivy。我意识到检测到致命错误。如果我使用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.py 文件,我会在 windows 和 linux 系统上听到声音。我按照以下步骤创建我的 exe: KIVY package 为 Windows My exe runs if i do not use SoundLoader lines.如果我不使用 SoundLoader 行,我的 exe 就会运行。 But if i add that, i can't even open console or app because this error appears.Thanks for advices.但是,如果我添加它,我什至无法打开控制台或应用程序,因为会出现此错误。感谢您的建议。

If you have same problem , Fix this lines in your .spec file:如果您有同样的问题,请在.spec文件中修复此行:

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..为我工作..

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)],

The next thing helped me:接下来的事情帮助了我:

python -m pip install kivy[full]

This overlaped prior conda installation:这与之前的 conda 安装重叠:

conda install -c conda-forge kivy

After that mp3 file played fine.之后 mp3 文件播放正常。

Packages alteration after installation from pip (my dir):从 pip(我的目录)安装后的软件包更改:

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM