尝试将简单的Kivy GUI应用程序(只是一个文本文件解析器)打包到Win 7上的单个.exe for Windows中。当我在本地计算机上运行Kivy(未打包)时,它可以正常运行并完成我需要的一切它来。当我尝试运行打包版本时,我遇到了运行时错误:“R6034应用程序尝试错误地加载C运行时库。”
这是从PowerShell运行exe时得到的控制台stdout和stderr(以及弹出R6034消息的错误对话框):
[INFO ] [Kivy ] v1.9.0
[INFO ] [Python ] v2.7.2 (default, Jun 24 2011, 12:21:10) [MSC v.1500 32 bit (Intel)]
[INFO ] [Factory ] 173 symbols loaded
[INFO ] [Image ] Providers: img_tex, img_dds, img_gif, img_sdl2 (img_pil, img_ffpyplayer ignored)
[INFO ] [Text ] Provider: sdl2
[ERROR ] [filechooser ] win32file module is missing
[ERROR ] [filechooser ] we cant check if a file is hidden or not
[INFO ] [OSC ] using <thread> for socket
[INFO ] [Window ] Provider: sdl2
[INFO ] [GL ] GLEW initialization succeeded
[INFO ] [GL ] OpenGL version <4.2.0 - Build 10.18.10.3621>
[INFO ] [GL ] OpenGL vendor <Intel>
[INFO ] [GL ] OpenGL renderer <Intel(R) HD Graphics 4400>
[INFO ] [GL ] OpenGL parsed version: 4, 2
[INFO ] [GL ] Shading version <4.20 - Build 10.18.10.3621>
[INFO ] [GL ] Texture max size <16384>
[INFO ] [GL ] Texture max units <32>
[WARNING ] [Image ] Unable to load image
<C:\Users\ZM~1\AppData\Local\Temp\_MEI124202\kivy_install\data\glsl\default.png>
[CRITICAL ] [Window ] Unable to find any valuable Window provider at all!
sdl2 - Exception: SDL2: Unable to load image
File "C:\tmp\Kivy-1.9.0-py2.7-win32-x86\tsapp\build\main\out00-PYZ.pyz\kivy.core", line 65, in core_select_lib
File "C:\tmp\Kivy-1.9.0-py2.7-win32-x86\tsapp\build\main\out00-PYZ.pyz\kivy.core.window.window_sdl2", line 121, in
__init__
File "C:\tmp\Kivy-1.9.0-py2.7-win32-x86\tsapp\build\main\out00-PYZ.pyz\kivy.core.window", line 616, in __init__
File "C:\tmp\Kivy-1.9.0-py2.7-win32-x86\tsapp\build\main\out00-PYZ.pyz\kivy.core.window.window_sdl2", line 188, in
create_window
File "C:\tmp\Kivy-1.9.0-py2.7-win32-x86\tsapp\build\main\out00-PYZ.pyz\kivy.core.window", line 769, in create_window
File "kivy\graphics\instructions.pyx", line 751, in kivy.graphics.instructions.RenderContext.__init__
(kivy\graphics\instructions.c:10270)
File "C:\tmp\Kivy-1.9.0-py2.7-win32-x86\tsapp\build\main\out00-PYZ.pyz\kivy.core.image", line 511, in __init__
File "C:\tmp\Kivy-1.9.0-py2.7-win32-x86\tsapp\build\main\out00-PYZ.pyz\kivy.core.image", line 699, in _set_filename
File "C:\tmp\Kivy-1.9.0-py2.7-win32-x86\tsapp\build\main\out00-PYZ.pyz\kivy.core.image", line 429, in load
File "C:\tmp\Kivy-1.9.0-py2.7-win32-x86\tsapp\build\main\out00-PYZ.pyz\kivy.core.image", line 197, in __init__
File "C:\tmp\Kivy-1.9.0-py2.7-win32-x86\tsapp\build\main\out00-PYZ.pyz\kivy.core.image.img_sdl2", line 42, in load
[CRITICAL ] [App ] Unable to get a Window, abort.
我在应用程序中使用的唯一图像是背景图像,但即使我评论加载文件的部分并重新打包它也会给我带来相同的错误信息。
这是我正在使用的spec文件:
# -*- mode: python -*-
from kivy.tools.packaging.pyinstaller_hooks import install_hooks
import os
install_hooks(globals())
a = Analysis(['C:\\tmp\\tsapp\\main.py'],
pathex=['C:\\tmp\\Kivy-1.9.0-py2.7-win32-x64\\tsapp'],
hiddenimports=[],
runtime_hooks=None)
pyz = PYZ(a.pure)
exe = EXE(pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
name='main.exe',
debug=False,
strip=None,
upx=True,
console=True,
icon='C:\\tmp\\tsapp\\media\\excavator.ico'
)
coll = COLLECT(exe,
Tree("C:\\tmp\\tsapp"),
Tree(
[f for f in os.environ.get('KIVY_SDL2_PATH', '').split(';') if 'bin' in f][0]),
a.binaries,
a.zipfiles,
a.datas,
strip=None,
upx=True,
name='main'
)
我怀疑这只是我的Windows安装上的一些我尚未想到的东西 - 我不是最熟悉Windows的打包。