On this page
subprocess.call
Up: subprocess | Next: subprocess.CalledProcessError
Rel: subprocess.CalledProcessError, subprocess.check_call, subprocess.check_output, subprocess.CompletedProcess
Ref: docs.python.org — subprocess.call
Tags: #public #python3 #stdlib #subprocess
Import
import subprocess
from subprocess import call
Signature & Overview
subprocess.call(*popenargs, timeout=None, **kwargs)
Run command with arguments. Wait for command to complete or for timeout seconds, then return the returncode attribute.
Usage
import subprocess
import sys
rc = subprocess.call([sys.executable, "-c", "pass"])
assert rc == 0
Gotchas
- Legacy helper: Prefer
subprocess.run(...)in new code—it supportscapture_output=True,text=True, andcheck=Trueuniformly. - Does not raise on failure:
call()simply returns the integer exit code.
REPL Inspect
from subprocess import call
help(call)
Linked from
- tuts/python3/stdlib_module/subprocess
- tuts/python3/stdlib_module/subprocess/CalledProcessError
- tuts/python3/stdlib_module/subprocess/check_call
- 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/CalledProcessError Linked here; links to this page; shared tags: #stdlib, #subprocess
- tuts/python3/stdlib_module/subprocess/check_call 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