关于py打包为exe时遇到的问题
去掉图片时,能生成正常的exe文件,但是加上图片后,也能显示生成EXE文件成功,但是运行时出现了错误,文件都有好好放在指定位置。显示 failed to execute script
附上部分代码
window=Tk()
img1= PhotoImage(file='2.gif')
Label(window,image=img1).pack()
window.geometry('400x240')
def xitong(): #这里是登录成功后显示的另一个界面
global img
app = Tk()
app.title('仓库系统')
img = PhotoImage(file='1.gif')
Label(app, image=img).pack()
app.mainloop()
def denglu():
name11=e1.get()
mima=e2.get()
if name11=='132123' and mima=='35510627':
window.destroy() #这里关闭了最开始的登录界面
xitong()
else:
messagebox.showinfo(message='密码错误')
window.mainloop()
打包时加上 --hidden-import=queue
即Parameters配置修改为:
Parameters:--hidden-import=queue -w -F $FileName$
eg:
pyinstaller --hidden-import=queue -w -F main.py
py 3.7 好像打包有点问题…… Hello. 发表于 2020-4-20 12:05
加了,还是显示failed to execute script 765838210 发表于 2020-4-20 12:17
加了,还是显示failed to execute script
把exe放到py文件同一路径
相对路径试试 拿个座a.a 765838210 发表于 2020-4-20 12:17
加了,还是显示failed to execute script
把exe放到py文件同一路径 1.gif和2.gif和exe在同一个目录下吗?可以试试把文件名加上路径再打包看看。
页:
[1]