If I save my code files as .pyw
, no console window appears - which is what I want - but if the code includes a call to os.system
, I still get a pes
The solution that Piotr describes is actually not as complicated as it may sound. Here is an example where a startupinfo
is passed to a check_call
invocation to suppress the console window:
startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
subprocess.check_call(cmd, startupinfo=startupinfo)
Since the convenience functions call
, check_call
, and check_output
forward their **kwargs
to the Popen
constructor, it is not required to use Popen
directly.