我使用Pyinstaller创建了一个exe文件.
pyinstaller.exe --onefile --icon='Loco.ico program.py
Run Code Online (Sandbox Code Playgroud)
在程序中,我在我的图中包含一个图像,当我在其文件夹中单独运行程序时,我得到以下内容:
IOError: [Errno 2] No such file or directory: 'Logo.png'
Run Code Online (Sandbox Code Playgroud)
一种解决方案是将图像包含在exe文件夹中,如下面的链接所示:
但是再一次--onefile的全部意义就是拥有它,不需要另外的图像.我认为解决方案可能在这个链接中,但我还没有理解.
使用PyInstaller捆绑数据文件(--onefile)
我的spec文件看起来如下:
# -*- 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')
Run Code Online (Sandbox Code Playgroud) 如何在Qt创建的GUI上放置图像?屏幕的西南部分是空的,所以我希望只需点击一下按钮即可将图片放在那里,但我无法使用QPixmap和setPixmap.请在这件事上给予我帮助 !