765838210 发表于 2020-4-20 11:58:31

关于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()

Hello. 发表于 2020-4-20 12:05:31

打包时加上 --hidden-import=queue
即Parameters配置修改为:
Parameters:--hidden-import=queue -w -F $FileName$
eg:
pyinstaller --hidden-import=queue -w -F main.py

liuzhengyuan 发表于 2020-4-20 12:16:21

py 3.7 好像打包有点问题……

765838210 发表于 2020-4-20 12:17:29

Hello. 发表于 2020-4-20 12:05


加了,还是显示failed to execute script

Hello. 发表于 2020-4-20 12:25:17

765838210 发表于 2020-4-20 12:17
加了,还是显示failed to execute script

把exe放到py文件同一路径
相对路径试试

Pythonnewers 发表于 2020-4-20 12:52:30

拿个座a.a

Hello. 发表于 2020-4-20 12:58:16

765838210 发表于 2020-4-20 12:17
加了,还是显示failed to execute script

把exe放到py文件同一路径

txxcat 发表于 2020-4-20 14:11:46

1.gif和2.gif和exe在同一个目录下吗?可以试试把文件名加上路径再打包看看。
页: [1]
查看完整版本: 关于py打包为exe时遇到的问题