Want to glue Python to the rest of your system - call a compiled program, run a shell script, invoke Node.js, call Java, or pipe data to/from R? Enter subprocess . It’s Python’s standard way to start external programs, control their input/output, check return codes, set environments and timeouts — all with a solid API. Below is a practical, friendly guide: what subprocess is, why you’d use it, examples, best practices, pitfalls, and which languages/tools you can call from it. What is subprocess ? subprocess is a standard Python module that lets your Python program spawn new processes, connect to their input/output/error pipes, and obtain their return codes. It replaces older modules like os.system , popen and friends with a unified, safer interface. Key high-level primitives: subprocess.run() — simple, recommended for most cases (Python 3.5+). subprocess.Popen — lower-level, use when you need streaming IO, advanced control, or long-lived processes....
Home of tools