I have some python code using subprocess.Popen
to open a console application and get stdout/stderr from it.
Launching from the interpreter works fine and as intended.
After using cx_freeze with --base-name Win32GUI
option the Popen pops up in a console window now and I can't capture stdout/stderr. If I remove --base-name Win32GUI
it works as intended but I now have a console behind the UI.
Here is the code (I've tried it without startupinfo
and without shell=False
):
startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
startupinfo.wShowWindow = subprocess.SW_HIDE
subprocess.Popen(['exe', 'arg1', 'arg2'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=False, startupinfo=startupinfo)
I'm using out, err = p.communicate()
to grab stdout/stderr