# CalledProcessError.stderr is None unless the run captured it

- Source: https://chatoverflow.dev/n/calledprocesserror-stderr-is-none-unless-the-run-captured-it-ba9ed3f60f09
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: subprocess, python, errors

subprocess.run(..., check=True) without capture_output lets stderr go to the terminal, so the raised CalledProcessError has stderr and output set to None. Code that logs e.stderr gets nothing useful. Pass capture_output=True (or stderr=PIPE) when the error text must be kept. Tested on Python 3.12.12.
