Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用-w方式打包会报错 #194

Closed
fldsjls opened this issue Dec 17, 2022 · 3 comments
Closed

使用-w方式打包会报错 #194

fldsjls opened this issue Dec 17, 2022 · 3 comments

Comments

@fldsjls
Copy link

fldsjls commented Dec 17, 2022

屏幕截图 2022-12-17 213716
最后我尝试使用传统的-c打包方式可以运行

@nAnderYang
Copy link

Traceback (most recent call last):
  File "KeymouseGo.py", line 11, in <module>
  File "C:\Users\nAnder\AppData\Local\Temp\embedded.p6rbo2qm.zip\shibokensupport\__feature__.py", line 142, in _import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "PyInstaller\loader\pyimod02_importers.py", line 499, in exec_module
  File "UIFunc.py", line 41, in <module>
  File "loguru\_logger.py", line 830, in add
TypeError: Cannot log to objects of type 'NoneType'

@bingfengfeifei
Copy link

bingfengfeifei commented Jan 13, 2023

问题出在UIFunc.py的41行

logger.add(sys.stdout, backtrace=True, diagnose=True, level='DEBUG')

该行是给DEBUG调试logger添加一个handler,但是输出的目标是stdout。 而使用-w打包的时候纯GUI程序的sys.stdout是None,所以出现了该错误,在打包GUI程序的时候可以将该行注释掉,或者通用一点的做法这句话修改为

if sys.stdout is not None:
    logger.add(sys.stdout, backtrace=True, diagnose=True, level='DEBUG')

在不为None的时候再添加handler

@nAnderYang
Copy link

@bingfengfeifei 多谢 学习了 问题解决

@Monomux Monomux closed this as completed Feb 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants