I am trying to run Python scripts as a subprocess using subprocess.Popen:
interpreter = 'path/to/interpreter/python.exe'
program_name = 'pyscript.py'
args = ['argument_for_pyscript']
process = Popen([interpreter, program_name, *args], creationflags=CREATE_NEW_CONSOLE, stderr=PIPE)
As you can see, I want the subprocess to open in its own console window (which means it should print standard output to that console), but pipe all errors to the parent.
However, when I run this, a separate console window opens, but the "standard output" (normal print statements) get printed to the parent console. When I drop the stderr=PIPE argument, the "standard output" prints to the separate child console as intended, but errors won't get piped to the parent, of course.
Why should setting stderr=PIPE affect stdout like that? How can I achieve what I want?