【发布时间】:2015-10-28 10:35:38
【问题描述】:
我已经使用 Pyinstaller 创建了一个 exe 文件。
pyinstaller.exe --onefile --icon='Loco.ico program.py
在程序中,我在绘图中包含一个图像,当我在其文件夹中单独运行程序时,我得到以下信息:
IOError: [Errno 2] No such file or directory: 'Logo.png'
一种解决方案是将图像包含在 exe 的文件夹中,如下面的链接所示:
pyinstaller does not show images and icon
但话说回来,--onefile 的重点就是完全拥有它,而不需要另外的图像。我认为解决方案可能在这个链接中,但我没有理解它。
Bundling data files with PyInstaller (--onefile)
我的规范文件如下所示:
# -*- mode: python -*-
a = Analysis(['AMOS_Visualizer.py'],
pathex=['C:\\Users\\elu\\PycharmProjects\\Prosjektet\\Forsok splitting'],
hiddenimports=[],
hookspath=None,
runtime_hooks=None)
pyz = PYZ(a.pure)
exe = EXE(pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
name='AMOS_Visualizer.exe',
debug=False,
strip=None,
upx=True,
console=True , icon='AMOS.ico')
【问题讨论】:
标签: python pyinstaller