Using the Python subprocess Module
Python’ssubprocess module allows you to run shell commands and manage external processes directly from your Python code. By usingsubprocess, you can execute shell commands likels ordir, launch applications, and handle both input and output streams. This module provides tools for error handling and process communication, making it a flexible choice for integrating command-line operations into your Python projects.
By the end of this video course, you’ll understand that:
- The Python
subprocessmodule is used torun shell commands and manage external processes. - You run a shell command using
subprocessbycallingsubprocess.run()with the command as a list of arguments. subprocess.call(),subprocess.run(), andsubprocess.Popen()differ inhow they execute commands and handle process output and return codes.multiprocessingis forparallel execution within Python, whilesubprocessmanagesexternal processes.- To execute multiple commands in sequence using
subprocess, you can chain them byusing pipes or running them consecutively.
What’s Included:
- 14 Lessons
- Video Subtitles and Full Transcripts
- 2 Downloadable Resources
- Accompanying Text-Based Tutorial
- Q&A With Python Experts: Ask a Question
- Certificate of Completion
Downloadable Resources:
Related Learning Paths:
Getting Started With subprocess
8 Lessons 20m
- 1. Using the Python subprocess Module (Overview)01:40
- 2. Learning the subprocess Module03:11
- 3. Getting Started With the subprocess Module02:48
- 4. Using subprocess to Run Python02:03
- 5. Using subprocess to Run Any App01:40
- 6. Understanding the CompletedProcess Object02:43
- 7. Exploring Exceptions03:40
- 8. Raising a TimeoutExpired Error02:39
Streams and Pipes
6 Lessons 20m
AboutSteven Loyens
Steven is an Actuary, Economist and Engineer who found his passion for coding messing about with his Commodore 64 in the eighties. He loves understanding how things work and sharing that knowledge. He's an experienced coach and mentor.
» More about Steven














