cx_Freeze doesn't print to console

僤鯓⒐⒋嵵緔 提交于 2020-01-06 03:24:06

问题


I have an application that prints a few things to the console upon running. But as a standalone the executable doesn't print anything to the console?

The setup.py script looks like this:

import sys
from cx_Freeze import setup, Executable

setup(
    name = "My App",
    version = "1.0",
    options = {
        "build_exe" : {
            "include_files": ['MyImgs']
        },
    },
    executables = [Executable("Main.py", base = "Win32GUI")]
)

On the command line I run the following: py setup.py build

I then find the executable and run: Main.exe.

What I am missing for some reason is any print() statements. Is there something I need to include in the setup script for this to happen?


回答1:


If you use the "Win32GUI" base, then Windows does not make available stdout and stderr. You will need to redirect those yourself to some other location (such as a file). If you use the "Console" base then stdout and stderr are available and print() will work as expected -- but you will see a console created for you if you haven't run it from a console in the first place!



来源:https://stackoverflow.com/questions/38404800/cx-freeze-doesnt-print-to-console

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!