运行使用pyinstaller创建的exe时如何使'Kivy'ui持久化

时间:2018-12-21 19:33:15

标签: python kivy pyinstaller

尝试使用pyinstaller创建一个简单的exe文件,然后将其分发给其他用户。 python代码使用kivy创建前端。但是,当我运行exe(使用pyinstaller --onefile创建)时,命令窗口和kivy窗口会立即关闭。我想让ui持久化直到用户关闭它。

我正在使用Python 3.7

下面是简单的kivy代码

import kivy
from kivy.app import App
from kivy.uix.button import Button

class TestApp(App):
    def build(self):
        return Button(text='Hello World')

TestApp().run()

当我通过命令提示符运行exe时,我得到以下信息

[WARNING] [Image       ] Unable to load image <C:\Users\aa\AppData\Local\Temp\_MEI280362\kivy_install\data\glsl\default.png>
[CRITICAL] [Window      ] Unable to find any valuable Window provider.
sdl2 - Exception: SDL2: Unable to load image
  File "site-packages\kivy\core\__init__.py", line 67, in core_select_lib
  File "site-packages\kivy\core\window\window_sdl2.py", line 140, in __init__
  File "site-packages\kivy\core\window\__init__.py", line 968, in __init__
  File "site-packages\kivy\core\window\window_sdl2.py", line 294, in create_window
  File "site-packages\kivy\core\window\__init__.py", line 1216, in create_window
  File "kivy\graphics\instructions.pyx", line 759, in kivy.graphics.instructions.RenderContext.__init__
  File "site-packages\kivy\core\image\__init__.py", line 536, in __init__
  File "site-packages\kivy\core\image\__init__.py", line 732, in _set_filename
  File "site-packages\kivy\core\image\__init__.py", line 435, in load
  File "site-packages\kivy\core\image\__init__.py", line 201, in __init__
  File "site-packages\kivy\core\image\img_sdl2.py", line 41, in load

[CRITICAL] [App         ] Unable to get a Window, abort.

0 个答案:

没有答案