Python pyinstaller不显示图像和图标
我读了很多关于如何通过修改spec文件来包含图像和图标的教程,尽管我没有成功。我编写了一个程序,我想使用pyinstaller使其可执行并在其他计算机上运行。pyinstaller在主.exe文件中不包含图像和图标文件。当我在自己的电脑上运行编译后的.exe文件时,它工作正常,但当我尝试在其他电脑上运行相同的文件时,它会抛出一个错误。。请告诉我怎么做,这简直是疯了。。 提前谢谢。。 下面是我的.spec文件代码和python脚本(部分) .spec文件:Python pyinstaller不显示图像和图标,python,tkinter,pyinstaller,Python,Tkinter,Pyinstaller,我读了很多关于如何通过修改spec文件来包含图像和图标的教程,尽管我没有成功。我编写了一个程序,我想使用pyinstaller使其可执行并在其他计算机上运行。pyinstaller在主.exe文件中不包含图像和图标文件。当我在自己的电脑上运行编译后的.exe文件时,它工作正常,但当我尝试在其他电脑上运行相同的文件时,它会抛出一个错误。。请告诉我怎么做,这简直是疯了。。 提前谢谢。。 下面是我的.spec文件代码和python脚本(部分) .spec文件: # -*- mode: python -
# -*- mode: python -*-
a = Analysis(['English-Nepali.py'],
pathex=['C:\\Users\\User\\Desktop\\Dict'],
hiddenimports=[],
hookspath=None,
runtime_hooks=None)
pyz = PYZ(a.pure)
exe = EXE(pyz,
a.scripts,
exclude_binaries=True,
name='English-Nepali.exe',
debug=False,
strip=None,
upx=True,
console=True )
coll = COLLECT(exe,
a.binaries,
a.zipfiles,
a.datas,
strip=None,
upx=True,
name='English-Nepali')
作为使用图像和图标的程序的一部分,ico和jpg文件都存在于目录中:
class Demo2:
def __init__(self, master):
self.master = master
self.master.geometry("640x250+200+200")
master.resizable(False,False)
self.master.title('About')
self.img = Image.open(r"C:\Users\User\Desktop\Dict\rotunda.jpg")
self.tetras = ImageTk.PhotoImage(self.img)
def main():
root = tk.Tk()
ex = Example(root)
root.iconbitmap(r"C:\Users\User\Desktop\Dict\1.ico")
root.resizable(False,False)
root.mainloop()
将
.ico
和.jpg
文件放在pyinstaller
创建的文件夹中。我建议您添加错误消息。将.ico和.jpg文件放在pyinstaller创建的文件夹中creates@AlokChaudhary.. 这很有帮助,谢谢兄弟…在构建文件夹?