Ahmed Essam
Ahmed Essam

Reputation: 1010

How to disable log file for py2exe?

I've created a small script using Python and PyQt4, I converted it to exe. But there's some cases in my script that I'm not handling so a log file being created while using the program. So I wanna disable creating this log file.

How can I do that?

Here's my setup.py file:

from distutils.core import setup
import py2exe
setup(
    windows=['DumbCalculator.py'],
    options = {
        "py2exe": {
            "dll_excludes": ["MSVCP90.dll"],  
        }
    },
    )

Upvotes: 0

Views: 715

Answers (2)

Erik Knowles
Erik Knowles

Reputation: 1007

You can avoid editing the package, and avoid creating the log file, by adding the following to the top of your main .py file:

import sys
if sys.frozen == "windows_exe":
    sys.stderr._error = "inhibit log creation"

Upvotes: 0

Ahmed Essam
Ahmed Essam

Reputation: 1010

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.

I run py2exe again and tried the program works great. It makes a log file but doesn't run its annoying prompt. It worked for me !

Upvotes: 1

Related Questions