我一直有些麻烦将我的脚本转换为可执行文件,但最终我成功了。主要问题是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文件)在这里。
感谢您的帮助。
pyrcc4
将它们转换为.py
文件。在使用PyInstaller编译的资源文件中,我在PyQt脚本中没有遇到过问题。 - Avaris