subprocess.Popen takes a list of arguments:

from subprocess import Popen, PIPE

process = Popen(['swfdump', '/tmp/filename.swf', '-d'], stdout=PIPE, stderr=PIPE)
stdout, stderr = process.communicate()

There's even a section of the documentation devoted to helping users migrate from os.popen to subprocess.

Answer from Blender on Stack Overflow
🌐
Python
docs.python.org › 3 › library › subprocess.html
subprocess — Subprocess management
5 days ago - All of the functions and methods that accept a timeout parameter, such as run() and Popen.communicate() will raise TimeoutExpired if the timeout expires before the process exits. Exceptions defined in this module all inherit from SubprocessError.
Discussions

How to get output from subprocess.Popen along with visible execution?
I am trying to get the output by running below dummy code for my project - #test.py import time for x in range(5): print(i) time.sleep(1) This is test2.py import subprocess cmd = "python3 test.py" process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=true, text=true) ... More on discuss.python.org
🌐 discuss.python.org
6
1
July 22, 2024
subprocess.Popen and output
To avoid deadlock, I think you are supposed to say handbrake.communicate() if using pipes. But I'm not familiar with your technique of using pipes to suppress output, either. IME, pipes are for capturing output. There's a DEVNULL object for suppression. It's either stdout or stderr, at least on a UNIX. More on reddit.com
🌐 r/learnpython
18
22
December 7, 2022
🌐
Medium
medium.com › @AlexanderObregon › how-to-use-pythons-subprocess-module-to-run-system-commands-ffdeabcb9721
How to Use Python’s subprocess Module to Run System Commands
November 12, 2024 - import subprocess # Create a pipeline: echo -> grep process = subprocess.Popen(["grep", "hello"], stdin=subprocess.PIPE, stdout=subprocess.PIPE, text=True) output = process.communicate(input="hello world\npython subprocess\nhello again")[0] print("Filtered Output:") print(output)
🌐
Codecademy
codecademy.com › article › python-subprocess-tutorial-master-run-and-popen-commands-with-examples
Python Subprocess Tutorial: Master run() and Popen() Commands (with Examples) | Codecademy
Popen() provides granular control over process execution, input/output streaming, and chaining multiple processes, making it ideal for interactive or complex subprocess workflows.
🌐
Squash
squash.io › tutorial-subprocess-popen-in-python
Tutorial: Subprocess Popen in Python - Squash Labs
The subprocess module in Python ... their return codes. The subprocess.Popen class is a useful tool that allows you to create and interact with subprocesses in Python....
🌐
Stack Abuse
stackabuse.com › pythons-os-and-subprocess-popen-commands
Python's os and subprocess Popen Commands
November 9, 2017 - In addition the popen2, popen3, and popen4 are only available in Python 2 but not in Python 3. Python 3 has available the popen method, but it is recommended to use the subprocess module instead, which we'll describe in more detail in the following section.
Find elsewhere
🌐
DataCamp
datacamp.com › tutorial › python-subprocess
An Introduction to Python Subprocess: Basics and Examples | DataCamp
September 12, 2025 - This will run the command python ... and errors, respectively. subprocess.Popen is useful when you want more control over the process, such as sending input to it, receiving output from it, or waiting for it to complete....
🌐
Reddit
reddit.com › r/learnpython › subprocess.popen and output
r/learnpython on Reddit: subprocess.Popen and output
December 7, 2022 -

I'm trying to grok subprocess.Popen to run and monitor a command line executable in the background. (Specifically, the HandbrakeCLI video converter.)

In this I have been partially successful, using the following command:

handbrake = subprocess.Popen( cmd )

Where cmd is a list of parameters. When I do this, I can do other things while it's running, poll() it, and terminate it if desired, and unless I kill it, it runs to completion exactly the way I want. The problem is that I also want to suppress the output. No problem, right?

handbrake = subprocess.Popen( cmd, stdout=subprocess.PIPE )

This works, but there's still SOME output. Now, my first thought was that the messages I was seeing were techincally ERROR messages. So I tried two different methods:

handbrake = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE )
handbrake = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT )

In both cases, the subprocess launches, I can do other things, but... it doesn't do anything. I can see HandbrakeCLI in the task manager, but it's not using any resources (where it *should* be using nearly 100%), and no file has been created in the target directory.

This leaves me with two questions that may or may not be related:

  1. Why is redirecting stdout causing the program to do nothing?

  2. Where is that other output coming from, and how do I suppress it? (Helpfully, it doesn't contain any information I need to capture.)

🌐
GeeksforGeeks
geeksforgeeks.org › python › python-subprocess-module
Python subprocess module - GeeksforGeeks
1 week ago - import subprocess process = subprocess.Popen( ["python", "--version"], stdout=subprocess.PIPE, text=True ) output, _ = process.communicate() print(output) Output · Python 3.13.0 · Explanation: subprocess.Popen() starts the process · ...
🌐
Jython
jython.org › jython-old-sites › docs › library › subprocess.html
17.1. subprocess — Subprocess management — Jython v2.5.2 documentation
Interprocess Communication and ... or function name. New in version 2.4. The subprocess module allows you to spawn new processes, connect to their input/output/error pipes, and obtain their return codes....
🌐
GitHub
github.com › python › cpython › blob › main › Lib › subprocess.py
cpython/Lib/subprocess.py at main · python/cpython
· Main API · ======== run(...): Runs a command, waits for it to complete, then returns a · CompletedProcess instance. Popen(...): A class for flexibly executing a command in a new process ·
Author   python
🌐
Real Python
realpython.com › python-subprocess
The subprocess Module: Wrapping Programs With Python – Real Python
January 18, 2025 - To actually link up two processes with a pipe from within subprocess is something that you can’t do with run(). Instead, you can delegate the plumbing to the shell, as you did earlier in the Introduction to the Shell and Text Based Programs with subprocess section. If you needed to link up different processes without delegating any of the work to the shell, then you could do that with the underlying Popen() constructor.
🌐
Medium
medium.com › @techclaw › python-popen-understanding-subprocess-management-in-python-83cbc309e714
Python Popen: Understanding Subprocess Management in Python | by TechClaw | Medium
August 8, 2023 - In conclusion, Python Popen is a powerful tool for managing subprocesses in Python. It allows us to execute external commands, capture output, handle input/output streams, and perform asynchronous operations.
🌐
Python 101
python101.pythonlibrary.org › chapter19_subprocess.html
Chapter 19 - The subprocess Module — Python 101 1.0 documentation
Let’s make Popen wait for the program to finish: >>> program = "notepad.exe" >>> process = subprocess.Popen(program) >>> code = process.wait() >>> print(code) 0
🌐
Better Stack
betterstack.com › community › guides › scaling-python › python-subprocess
An Introduction to Python Subprocess | Better Stack Community
While subprocess.run() is convenient for most use cases, the subprocess.Popen class provides more control over process execution.
🌐
Python Module of the Week
pymotw.com › 3 › subprocess › index.html
subprocess — Spawning Additional Processes — PyMOTW 3
March 18, 2018 - The constructor for Popen takes arguments to set up the new process so the parent can communicate with it via pipes. It provides all of the functionality of the other modules and functions it replaces, and more. The API is consistent for all uses, and many of the extra steps of overhead needed ...
🌐
Readthedocs
pydoc-zh.readthedocs.io › en › latest › library › subprocess.html
17.1. subprocess — Subprocess management — Python 2.7.6 documentation
The full function signature is largely the same as that of the Popen constructor, except that stdout is not permitted as it is used internally. All other supplied arguments are passed directly through to the Popen constructor. ... >>> subprocess.check_output(["echo", "Hello World!"]) 'Hello World!\n' >>> subprocess.check_output("exit 1", shell=True) Traceback (most recent call last): ...
🌐
Stackify
stackify.com › a-guide-to-python-subprocess
A Guide to Python Subprocess - Stackify
January 21, 2025 - import subprocess # Create a process process = subprocess.Popen( ['sleep', '10'], stdout=subprocess.PIPE, stderr=subprocess.PIPE ) # Process management print(f"Process ID: {process.pid}") print(f"Process still running: {process.poll() is None}") # Wait for completion with timeout try: process.wait(timeout=5) except subprocess.TimeoutExpired: process.kill() print("Process killed after timeout") print(f"Final return code: {process.returncode}")