第一次使用pyinstaller, 我跑了 pyinstaller appname.py --icon='myicon.ico' 图标文件是使用 convertico.com 转换的,它位于我运行 pyinstaller 的同一目录中
在dist/appname/目录下,可执行的appname 图标依旧没有变化。 我做错什么了吗? 规范文件是:
# -*- mode: python -*-
block_cipher = None
a = Analysis(['appname.py'],
pathex=['/home/admin/appname'],
binaries=None,
datas=None,
hiddenimports=[],
hookspath=None,
runtime_hooks=None,
excludes=None,
win_no_prefer_redirects=None,
win_private_assemblies=None,
cipher=block_cipher)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
exclude_binaries=True,
name='appname',
debug=False,
strip=None,
upx=True,
console=True , icon='myicon.ico')
coll = COLLECT(exe,
a.binaries,
a.zipfiles,
a.datas,
strip=None,
upx=True,
name='appname')
最佳答案
成功了,只是缓存图标的问题。如果将 .exe
移动到另一个文件夹,图标应该会改变。只是为了确保重建使用:
pyinstaller --onefile --icon=myicon.ico --clean yourapp.py
--clean
命令清除缓存,您的图标将正确显示
关于python - pyinstaller:更改应用程序图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33114073/