Nuitka 加 --windows-disable-console 选项后隐藏的坑

Nuitka打包python,加 --windows-disable-console 选项后报错。

经过半天排查,终于查明是因为中文字符问题。(我没有使用中文,只是print的信息中有个中文感叹号,所以大大增加了我排查时间。 )

排查问题,从console看报错信息肯定是第一选择啊,但在console中这丫又好好的正常的,加了 --windows-disable-console 又不行了,这又增加了排查时间。最后只能把捕捉到错误信息保存到文本里面,才找到原因。

上代码:

import tkinter as tk

def test():
    print('HELLO WORLD')
    lblMsg["text"] = 'HELLO WORLD 打印成功'

def test2():
    try:
        print('世界你好')
    except:
        lblMsg["text"] = '捕捉到err'
    else:
        lblMsg["text"] = '世界你好 打印成功'

def test3():
    print('世界你好')
    lblMsg["text"] = 'I AM OK'


win=tk.Tk()
win.geometry("300x300")

lblMsg=tk.Label(win,text="test")
lblMsg.place(x=50,y=50)

tk.Button(win,text="print HELLO WORLD",command=test).place(x=100,y=100)
tk.Button(win,text="try 世界你好",command=test2).place(x=100,y=150)
tk.Button(win,text="no try世界你好",command=test3).place(x=100,y=200)

win.mainloop()

以上代码在如果用pyinstaller打包,有没有--noconsole 选项,功能都正常!

用Nuitka打包,不带--windows-disable-console 是正常的, 加上 --windows-disable-console 就不正常了。

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值