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?
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!