[英]How to disable log file for py2exe?
I've created a small script using Python
and PyQt4
, I converted it to exe
. 我使用
Python
和PyQt4
创建了一个小脚本,将其转换为exe
。 But there's some cases in my script that I'm not handling so a log
file being created while using the program. 但是在我的脚本中有一些情况我没有处理,因此在使用该程序时会创建一个
log
文件。 So I wanna disable creating this log
file. 所以我想禁用创建此
log
文件。
How can I do that? 我怎样才能做到这一点?
Here's my setup.py
file: 这是我的
setup.py
文件:
from distutils.core import setup
import py2exe
setup(
windows=['DumbCalculator.py'],
options = {
"py2exe": {
"dll_excludes": ["MSVCP90.dll"],
}
},
)
I finally found how to do that. 我终于找到了解决方法。
I went to C:\\Python27\\Lib\\site-packages\\py2exe
and then opened boot_common.py
file and commented the 56, 57, 58, 59, 60, 63, 64,65 lines and saved it. 我去了
C:\\Python27\\Lib\\site-packages\\py2exe
,然后打开boot_common.py
文件并注释了56、57、58、59、60、63、64、65行并保存了它。
I run py2exe again and tried the program works great. 我再次运行py2exe并尝试了该程序。 It makes a log file but doesn't run its annoying prompt.
它生成一个日志文件,但不运行其令人讨厌的提示。 It worked for me !
它为我工作!
You can avoid editing the package, and avoid creating the log file, by adding the following to the top of your main .py file: 通过在主.py文件的顶部添加以下内容,可以避免编辑程序包并避免创建日志文件:
import sys
if sys.frozen == "windows_exe":
sys.stderr._error = "inhibit log creation"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.