您好我希望得到一些指导,说明为什么我不能让pyinstaller与Kivy合作。当我尝试启动程序时,CMD窗口会短暂出现然后崩溃。
我按照本教程https://kivy.org/docs/guide/packaging-windows.html上的步骤操作,我不确定glew32或sdl2,但我的kv文件已导入并复制到dist \ app文件夹。
该程序将在python环境中完美运行。我也使用pyinstaller安装了这个程序,没有kivy GUI,它按预期工作。
以下是kivy错误日志,其中显示sdl2不能正确导入。 dist \ app文件夹中有一个glew32.dll文件和各种sdl2.dll文件。
错误日志
[INFO ] Logger: Record log in C:\Users\mconn\.kivy\logs\kivy_17-10-
30_53.txt
[INFO ] Kivy: v1.10.0
[INFO ] Python: v2.7.12 (v2.7.12:d33e0cf91556, Jun 27 2016, 15:19:22) [MSC
v.1500 32 bit (Intel)]
[INFO ] Factory: 194 symbols loaded
[INFO ] Image: Providers: img_tex, img_dds, img_sdl2, img_gif (img_pil,
img_ffpyplayer ignored)
[INFO ] Text: Provider: sdl2
[INFO ] OSC: using <thread> for socket
[INFO ] Window: Provider: sdl2
[CRITICAL] Window: Unable to find any valuable Window provider.
sdl2 - ImportError: DLL load failed: The specified procedure could not be
found.
File "C:\Python27\ArcGIS10.5\lib\site-packages\kivy\core\__init__.py",
line 67, in core_select_lib
cls = cls()
File "C:\Python27\ArcGIS10.5\lib\site-
packages\kivy\core\window\window_sdl2.py", line 140, in __init__
super(WindowSDL, self).__init__()
File "C:\Python27\ArcGIS10.5\lib\site-
packages\kivy\core\window\__init__.py", line 899, in __init__
self.create_window()
File "C:\Python27\ArcGIS10.5\lib\site-
packages\kivy\core\window\window_sdl2.py", line 269, in create_window
self.fullscreen, resizable, state)
File "kivy\core\window\_window_sdl2.pyx", line 110, in
kivy.core.window._window_sdl2._WindowSDL2Storage.setup_window
(kivy\core/window\_window_sdl2.c:2436)
File "kivy\graphics\cgl.pyx", line 52, in
kivy.graphics.cgl.cgl_get_backend_name (kivy\graphics\cgl.c:3044)
File "kivy\graphics\cgl.pyx", line 60, in
kivy.graphics.cgl.cgl_get_backend_name (kivy\graphics\cgl.c:2879)
File "C:\Python27\ArcGIS10.5\lib\importlib\__init__.py", line 37, in
import_module
__import__(name)
File "c:\users\mconn\appdata\local\temp\pip-build-
wy26bb\pyinstaller\PyInstaller\loader\pyimod03_importers.py", line 687, in
load_module
[CRITICAL] App: Unable to get a Window, abort.
.spec代码
# -*- mode: python -*-
from kivy.deps import sdl2, glew
block_cipher = None
a = Analysis(['C:\\Users\\mconn\\Desktop\\Python Course\\Crash Locator\\Python Program\\FARS_crash_summary.py'],
pathex=['C:\\Users\\mconn\\Desktop\\Python Course\\Crash Locator\\Program'],
binaries=[],
datas=[],
hiddenimports=[],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
exclude_binaries=True,
name='CrashLocator',
debug=False,
strip=False,
upx=True,
console=True )
coll = COLLECT(exe, Tree('C:\\Users\\mconn\\Desktop\\Python Course\\Crash Locator\\Python Program\\'),
a.binaries,
a.zipfiles,
a.datas,
*[Tree(p) for p in (sdl2.dep_bins + glew.dep_bins)],
strip=False,
upx=True,
name='CrashLocator')