subprocess.CalledProcessError
subprocess.CalledProcessError is a Python function in the Subprocess Module category. Exception raised when check_call() or check_output() detects a non-zero exit code. The syntax is subprocess.CalledProcessError(returncode, cmd, output=None, stderr=None). Returns: Exception. A typical example: try:
subprocess.check_call(["false"])
except subprocess.CalledProcessError as e:
print(f"Exit code: {e.returncode}"). A close sibling is subprocess.run(), which runs a command and waits for it to complete. Returns a CompletedProcess instance. A close sibling is subprocess.Popen(), which executes a child program in a new process (lower-level than run()). A close sibling is Popen.communicate(), which sends data to stdin and reads from stdout/stderr until EOF. A close sibling is subprocess.call(), which runs a command and returns its return code (legacy API, use run() instead). More about this category: Subprocess management — run, Popen, call, PIPE, CalledProcessError. For a broader walkthrough, read the Subprocess Module guide. Related Subprocess Module entries: subprocess.run(), subprocess.Popen(), Popen.communicate(), subprocess.call(), subprocess.check_output(), subprocess.check_call().