Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cx_Freeze doesn't print to console

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?

like image 844
Max Avatar asked Oct 17 '25 08:10

Max


1 Answers

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!

like image 168
Anthony Tuininga Avatar answered Oct 19 '25 23:10

Anthony Tuininga



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!