【发布时间】:2012-07-17 01:41:42
【问题描述】:
我在将脚本传递到可执行文件时遇到了一些复杂问题,但我终于成功了。主要问题是 PyInstaller 不会将图像加载到 GUI。
它应该是这样的:
看起来是这样的:
而且我似乎找不到问题,这是 .spec 文件:
a = Analysis([os.path.join(HOMEPATH,'support\\_mountzlib.py'), os.path.join(HOMEPATH,'support\\useUnicode.py'), 'programa.py'],
pathex=['img', 'C:\\Users\\Poblet\\ManGet\\HeyMang\\pyinstaller'])
pyz = PYZ(a.pure)
exe = EXE(pyz,
a.scripts,
exclude_binaries=1,
name=os.path.join('build\\pyi.win32\\Hey Mang!', 'Hey Mang!.exe'),
debug=False,
icon='heymang.ico',
strip=False,
upx=True,
console=False )
coll = COLLECT( exe,
Tree('C:\\Users\\Poblet\\ManGet\\HeyMang\\pyinstaller\\img'),
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=True,
name=os.path.join('dist', 'Hey Mang!'))
app = BUNDLE(coll,
name=os.path.join('dist', 'Hey Mang!.app'))
它应该抓取这些图像,就像这里所说的那样:
Warnings written to C:\Users\Poblet\ManGet\HeyMang\pyinstaller\Hey Mang!\warnHey Mang!.txt
checking PYZ
rebuilding outPYZ1.toc because outPYZ1.pyz is missing
building PYZ outPYZ1.toc
checking PKG
rebuilding outPKG3.toc because outPKG3.pkg is missing
building PKG outPKG3.pkg
checking EXE
rebuilding outEXE2.toc because Hey Mang!.exe missing
building EXE from outEXE2.toc
I: SRCPATH [('heymang.ico', None)]
I: Updating icons from ['heymang.ico'] to c:\users\poblet\appdata\local\temp\tmpr34zmp
I: Writing RT_GROUP_ICON 0 resource with 76 bytes
I: Writing RT_ICON 1 resource with 1128 bytes
I: Writing RT_ICON 2 resource with 4264 bytes
I: Writing RT_ICON 3 resource with 9640 bytes
I: Writing RT_ICON 4 resource with 16936 bytes
I: Writing RT_ICON 5 resource with 67624 bytes
它们在文件夹中,但由于某种原因它们不起作用。
整个源代码(减去 PyInstaller 文件)是here。
感谢您的帮助。
【问题讨论】:
-
不能直接解决您的问题,但您可以尝试使用Qt Resource System 和
pyrcc4将它们转换为.py文件。我在 PyQt 脚本中使用 PyInstaller 编译的资源文件没有问题。
标签: python python-2.7 pyqt4 pyinstaller