On this page
  1. subprocess.CalledProcessError
  2. Import
  3. Signature & Overview
  4. Methods & Attributes
  5. Usage
  6. Gotchas
  7. REPL Inspect

subprocess.CalledProcessError

Prev: subprocess.call | Up: subprocess | Next: subprocess.check_call
Rel: subprocess.call, subprocess.check_call, subprocess.check_output, subprocess.CompletedProcess
Ref: docs.python.org — subprocess.CalledProcessError
Tags: #public #python3 #stdlib #subprocess


Import

import subprocess
from subprocess import CalledProcessError

Signature & Overview

subprocess.CalledProcessError(returncode, cmd, output=None, stderr=None)

Raised when run() is called with check=True and the process returns a non-zero exit status.

Methods & Attributes

Usage

import subprocess
import sys

try:
    subprocess.run([sys.executable, "-c", "raise SystemExit(2)"], check=True, capture_output=True, text=True)
except subprocess.CalledProcessError as exc:
    assert exc.returncode == 2

Gotchas

REPL Inspect

from subprocess import CalledProcessError
help(CalledProcessError)

Linked from

Related notes