On this page
subprocess.check_call
Prev: subprocess.CalledProcessError | Up: subprocess | Next: subprocess.check_output
Rel: subprocess.call, subprocess.CalledProcessError, subprocess.check_output, subprocess.CompletedProcess
Ref: docs.python.org — subprocess.check_call
Tags: #public #python3 #stdlib #subprocess
Import
import subprocess
from subprocess import check_call
Signature & Overview
subprocess.check_call(*popenargs, **kwargs)
Run command with arguments. Wait for command to complete. If the exit code was zero then return, otherwise raise CalledProcessError. The CalledProcessError object will have the
Usage
import subprocess
import sys
rc = subprocess.check_call([sys.executable, "-c", "pass"])
assert rc == 0
Gotchas
- Legacy helper: Equivalent to
subprocess.run(..., check=True).returncode. - Does not capture stdout: Output goes straight to the parent's stdout/stderr; use
subprocess.run(..., check=True, capture_output=True)if you need the text.
REPL Inspect
from subprocess import check_call
help(check_call)
Linked from
- tuts/python3/stdlib_module/subprocess
- tuts/python3/stdlib_module/subprocess/call
- tuts/python3/stdlib_module/subprocess/CalledProcessError
- tuts/python3/stdlib_module/subprocess/check_output
- tuts/python3/stdlib_module/subprocess/CompletedProcess
- tuts/python3/stdlib_module/subprocess/getoutput
- tuts/python3/stdlib_module/subprocess/getstatusoutput
- tuts/python3/stdlib_module/subprocess/Popen
- tuts/python3/stdlib_module/subprocess/run
- tuts/python3/stdlib_module/subprocess/SubprocessError
- tuts/python3/stdlib_module/subprocess/TimeoutExpired
Related notes
- tuts/python3/stdlib_module/subprocess/call Linked here; links to this page; shared tags: #stdlib, #subprocess
- tuts/python3/stdlib_module/subprocess/CalledProcessError Linked here; links to this page; shared tags: #stdlib, #subprocess
- tuts/python3/stdlib_module/subprocess/check_output Linked here; links to this page; shared tags: #stdlib, #subprocess
- tuts/python3/stdlib_module/subprocess/CompletedProcess Linked here; links to this page; shared tags: #stdlib, #subprocess
- tuts/python3/stdlib_module/subprocess Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/subprocess/getoutput links to this page; shared tags: #stdlib, #subprocess
- tuts/python3/stdlib_module/subprocess/getstatusoutput links to this page; shared tags: #stdlib, #subprocess
- tuts/python3/stdlib_module/subprocess/Popen links to this page; shared tags: #stdlib, #subprocess
- tuts/python3/stdlib_module/subprocess/run links to this page; shared tags: #stdlib, #subprocess
- tuts/python3/stdlib_module/subprocess/SubprocessError links to this page; shared tags: #stdlib, #subprocess