Reading from https://docs.python.org/3/library/subprocess.html#subprocess.CompletedProcess """ If you ran the process with stderr=subprocess.STDOUT, stdout and stderr will be combined in this attribute, and stderr will be None. """ But, if you run `run()` with `capture_output=True`, you get the following exception: """ ValueError: stdout and stderr arguments may not be used with capture_output. """ So, it seems impossible to get the combined outputs of stdout and stderr with `run()`.
Are you using something like below? This exception was added with ce0f33d04528fcafc673a8707871f8430d8f7ce8 () >>> subprocess.run('ls', stdout=subprocess.PIPE, capture_output=True) Traceback (most recent call last): File "", line 1, in File "/Users/karthikeyansingaravelan/stuff/python/cpython/Lib/subprocess.py", line 469, in run raise ValueError('stdout and stderr arguments may not be used ' ValueError: stdout and stderr arguments may not be used with capture_output. There is a note on the docs and a discussion on the issue that capture_output and stdout/stderr cannot be used at the same time. https://docs.python.org/3/library/subprocess.html#subprocess.run > If capture_output is true, stdout and stderr will be captured. When used, the internal Popen object is automatically created with stdout=PIPE and stderr=PIPE. The stdout and stderr arguments may not be supplied at the same time as capture_output.
Python 3.7 added the "capture_output" parameter, for Issue 32102. Before that change, you could use "subprocess.PIPE": https://docs.python.org/3.6/library/subprocess.html#subprocess.run “To [capture output], pass PIPE for the ‘stdout’ and/or ‘stderr’ arguments” Since "capture_output" was added, it looks like you can still pass "subprocess.PIPE" on your own, but the documentation now only gives subtle hints that this might be supported. This was also brought up in Issue 33319.