我運行構建命令和一切似乎正確地增建,直到我嘗試推出的exe和這個彈出消息:Pyinstaller:圖片不能提取
這裏是我的規格文件,我不知道爲什麼它似乎是與兩個圖像梳理文件路徑。
block_cipher = None
a = Analysis(['TripCalc.py'],
pathex=['C:\\Users\\test\\Downloads\\TripApp'],
binaries=[],
datas=[('C:\\Users\\test\\Downloads\\TripApp\\BennySM.ico', 'C:\\Users\\test\\Downloads\\TripApp\\BgSM.gif')],
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,
a.binaries,
a.zipfiles,
a.datas,
name='TripCalc',
debug=False,
strip=False,
upx=True,
console=False ,
icon='C:\\Users\\test\\Downloads\\TripApp\\Benny.ico')
我嘗試添加DATAS旁邊的文件:
('Benny.ico', 'C:\\Users\\test\\Downloads\\TripApp\\BennySM.ico', 'data', 'BgSM.gif', 'C:\\Users\\test\\Downloads\\TripApp\\BgSM.gif', 'data')
,但它不會與ValueError: too many values to unpack (expected 2)
建設。
我跟着從這篇文章的例子如何將文件路徑添加到主python文件。 Bundling data files with PyInstaller --onefile
我能夠構建exe文件並將其與註釋掉的圖像一起運行。任何幫助將非常感激。
當我得到的數值錯誤消息我安裝具有以下規範文件:
block_cipher = None
a = Analysis(['TripCalc.py'],
pathex=['C:\\Users\\test\\Downloads\\TripApp'],
binaries=[],
datas=[('Benny.ico','C:\\Users\\test\\Downloads\\TripApp\\BennySM.ico','data','BgSM.gif','C:\\Users\\test\\Downloads\\TripApp\\BgSM.gif','data')],
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,
a.binaries,
a.zipfiles,
a.datas,
name='TripCalc',
debug=False,
strip=False,
upx=True,
console=False ,
icon='C:\\Users\\test\\Downloads\\TripApp\\Benny.ico')
錯誤窗口
這些變化對規範文件都建立但failed to launch script pops啓動exe時啓動。如果他們與exe文件打包,他們應該被定位在應用程序數據中的臨時文件中是否正確?
謝謝!