【问题标题】:Kivy to Exe with PyInstaller. [Failed to execute script main] because of SoundLoaderKivy 到 Exe 与 PyInstaller。 [无法执行脚本 main] 因为 SoundLoader
【发布时间】:2020-08-24 15:09:28
【问题描述】:

我正在尝试将我的 .py 文件转换为 .exe。我在我的 .py 文件中使用 kivy。我意识到检测到致命错误。如果我使用 SoundLoader.load('test.wav'),则无法执行脚本主错误。 主.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()

如果我运行我的 .py 文件,我会在 windows 和 linux 系统上听到声音。我按照以下步骤创建我的 exe:KIVY package for Windows。如果我不使用 SoundLoader 行,我的 exe 就会运行。但是如果我添加它,我什至无法打开控制台或应用程序,因为出现此错误。感谢您的建议。

【问题讨论】:

  • 您是否在规范文件的datas 中包含test.wav
  • 我将我的 .wav 添加到数据中。之后我收到此错误:File "kivy\lib\gstplayer_gstplayer.pyx",第 233 行,在 kivy.lib.gstplayer._gstplayer.GstPlayer.load kivy.lib.gstplayer._gstplayer.GstPlayerException: Unable to create a playbin. 考虑将环境 GST REGISTRY 设置为用户可访问的路径,例如 ~/registry.bin ... [下一行:] [428] 无法执行脚本 main

标签: python kivy exe pyinstaller


【解决方案1】:

如果您有同样的问题,请在您的 .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)],
...
...

为我工作..

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-08-12
    • 2018-12-09
    • 2023-03-15
    • 2022-10-23
    • 1970-01-01
    • 1970-01-01
    • 2019-08-03
    相关资源
    最近更新 更多