My problem is that py2exe is generating a log file when I run. It doesn't generate because I have an error when running the program. At the log file there is the standard console print out!

How can I do it that no log file would generate?

here my py2exe setup code:

from distutils.core import setup
import py2exe, sys, os
sys.argv.append('py2exe')
setup(
    options = {'py2exe': {'bundle_files': 1, 'compressed': True}},
    windows = [{'script': "run.py"}],
    zipfile = None
)
有帮助吗?

解决方案

In GUI applications, Py2exe redirects sys.stderr to a log file and sys.stdout to an object that ignores all writes. To avoid the log file, do this in your program at the top of the main module:

import sys
sys.stderr = sys.stdout

Or, let py2exe create a console application by using the console keyword instead of windows in setup.py.

其他提示

Probably you can remove the content of the file! It can work, but you must see if your programm needs some function defined there and then it can get errors!

At the chat you said that you want to use Python 3 but Py2Exe isn't there... Why don't you use cx_Freeze? It generates a bin and an .exe file. You can make an Installation with InnoSetup and you Game is perfect!

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top