【发布时间】:2021-07-21 18:55:14
【问题描述】:
我有一个正在运行的 kivy 应用程序,当我从 vscode 启动它时它运行良好。但是当我尝试用
制作一个exe文件时pyinstaller --onefile --icon=icons/levermannApp.ico --exclude-module matplotlib LevermannApp.py
然后启动程序我得到这个错误信息
[CRITICAL] [Window ] Unable to find any valuable Window provider. Please enable debug logging (e.g. add -d if running from the command line, or change the log level in the config) and re-run your app to identify potential causes
sdl2 - Exception: SDL2: Unable to load image
File "kivy\core\__init__.py", line 70, in core_select_lib
File "kivy\core\window\window_sdl2.py", line 152, in __init__
File "kivy\core\window\__init__.py", line 982, in __init__
File "kivy\core\window\window_sdl2.py", line 311, in create_window
File "kivy\core\window\__init__.py", line 1268, in create_window
File "kivy\graphics\instructions.pyx", line 783, in kivy.graphics.instructions.RenderContext.__init__
File "kivy\core\image\__init__.py", line 561, in __init__
File "kivy\core\image\__init__.py", line 754, in _set_filename
File "kivy\core\image\__init__.py", line 460, in load
File "kivy\core\image\__init__.py", line 223, in __init__
File "kivy\core\image\img_sdl2.py", line 47, in load
Traceback (most recent call last):
File "LevermannApp.py", line 28, in <module>
class MyLayout(Widget):
File "LevermannApp.py", line 29, in MyLayout
Window.size = (550, 700)
AttributeError: 'NoneType' object has no attribute 'size'
[49080] Failed to execute script LevermannApp
我的部分代码如下所示:
class MyLayout(Widget):
Window.size = (550, 700)
class LevermannScore(App):
def build(self):
return MyLayout()
if __name__ == "__main__":
LevermannScore().run()
我的规范文件如下所示:
# -*- mode: python ; coding: utf-8 -*-
block_cipher = None
a = Analysis(['LevermannApp.py'],
pathex=['C:\\Users\\Polzi\\Documents\\DEV\\Python-Private'],
binaries=[],
datas=[],
hiddenimports=[],
hookspath=[],
runtime_hooks=[],
excludes=['matplotlib'],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
[],
name='LevermannApp',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=True , icon='icons\\levermannApp.ico')
任何想法为什么程序在 vscode 上运行良好但不是可执行文件? (过去我已经能够使用 pyinstaller 为这个程序制作一个 exe 文件 - 但现在我再次尝试并得到上述错误......)
【问题讨论】:
标签: python kivy pyinstaller