Open HSLix opened 9 months ago
首先感谢大佬制作的nb_log,省了很多事,同时也促进我去学习pythonpath等知识 然后,我在用installer打包我的程序时,有按照9.4添加nb_log_config,但运行后程序有如下报错
……AttributeError: 'NoneType' object has no attribute 'write'
喂给gpt后,提示我问题出在File "nb_log\simple_print.py", line 19, in stderr_write
于是我上网找答案,在simple_print.py 19行加入以下代码解决问题,希望对其它人有用
for _name in ('stdin', 'stdout', 'stderr'): if getattr(sys, _name) is None: setattr(sys, _name, open(os.devnull, 'r' if _name == 'stdin' else 'w'))
然后也想请作者解答一下原因,比如应对这个问题还有什么更好的办法来解决 总之多谢作者的辛苦工作和无私奉献
的确是,用win32serviceutil服务方式后台运行也是报错AttributeError: 'NoneType' object has no attribute 'write',
打包后运行, sys.stderr是None,None没有.write方法, 你升级下nb_log 11.6版本,我改了.
首先感谢大佬制作的nb_log,省了很多事,同时也促进我去学习pythonpath等知识 然后,我在用installer打包我的程序时,有按照9.4添加nb_log_config,但运行后程序有如下报错
……AttributeError: 'NoneType' object has no attribute 'write'
喂给gpt后,提示我问题出在File "nb_log\simple_print.py", line 19, in stderr_write
于是我上网找答案,在simple_print.py 19行加入以下代码解决问题,希望对其它人有用
添加stderr通道
for _name in ('stdin', 'stdout', 'stderr'): if getattr(sys, _name) is None: setattr(sys, _name, open(os.devnull, 'r' if _name == 'stdin' else 'w'))
然后也想请作者解答一下原因,比如应对这个问题还有什么更好的办法来解决 总之多谢作者的辛苦工作和无私奉献