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
🌐
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
Use subprocess.PIPE to access them from Python. shell: If True, the command will be run through the shell. cwd: Set the working directory for the new process. env: A dictionary of environment variables for the new process. text / universal_newlines: If True, treats input/output as text strings instead of bytes. bufsize: Buffering policy. 0 for unbuffered, 1 for line-buffered, or any integer for block buffering. ... process = subprocess.Popen('more', stdin=subprocess.PIPE, stdout=subprocess.PIPE, text=True, shell=True)
🌐
Squash
squash.io › tutorial-subprocess-popen-in-python
Tutorial: Subprocess Popen in Python - Squash Labs
November 2, 2023 - To read from the subprocess's standard output or error stream, we can use the communicate method. This method waits for the subprocess to complete and returns a tuple containing the output and error streams.
Discussions

How to use subprocess popen Python - Stack Overflow
import shlex from subprocess import ... stderr = process.communicate() ... sh, it's good, however it's not same with Popen of subprocess. sh is alike with call of subprocess. 2015-07-20T12:16:59.583Z+00:00 ... Find the answer to your question by asking. Ask question ... See similar questions with these tags. ... 18 Python: executing ... More on stackoverflow.com
🌐 stackoverflow.com
Please help me understand how subprocess.popen works
Hello Python Masters…I am a beginner…Please help me understand how this code works: PyLocScript = r"C:\Phyton\PyApps\CSV_values_analyze.py" CsvLink = r"C:\Phyton\PyApps\sample.csv" PartNo = "LM3339" area = 45 xcor = 1.5… More on discuss.python.org
🌐 discuss.python.org
3
0
November 4, 2022
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
🌐
DataCamp
datacamp.com › tutorial › python-subprocess
An Introduction to Python Subprocess: Basics and Examples | DataCamp
September 12, 2025 - This will run the command python –help and create a new Popen object, which is stored in the variable p. The standard output and error of the command are captured using the communicate() method and stored in the variables output and errors, respectively. subprocess.Popen is useful when you want more control over the process...
🌐
Python
docs.python.org › 3 › library › subprocess.html
subprocess — Subprocess management
1 week ago - If used it must be a byte sequence, or a string if encoding or errors is specified or text is true. When used, the internal Popen object is automatically created with stdin set to PIPE, and the stdin argument may not be used as well. If check is true, and the process exits with a non-zero exit code, a CalledProcessError exception will be raised.
🌐
Real Python
realpython.com › python-subprocess
The subprocess Module: Wrapping Programs With Python – Real Python
January 18, 2025 - Some documented changes have happened ... this tutorial. Most of your interaction with the Python subprocess module will be via the run() function. This blocking function will start a process and wait until the new process exits before moving on. The documentation recommends using run() for all cases that it can handle. For edge cases where you need more control, the Popen class can ...
Find elsewhere
🌐
Rip Tutorial
riptutorial.com › more flexibility with popen
Python Language Tutorial => More flexibility with Popen
process = subprocess.Popen([r'C:\path\to\app.exe'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) # This will block until process completes stdout, stderr = process.communicate() print stdout print stderr
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-subprocess-module
Python subprocess module - GeeksforGeeks
2 weeks ago - ... import subprocess process = subprocess.Popen( ["python"], stdin=subprocess.PIPE, stdout=subprocess.PIPE, text=True ) output, _ = process.communicate("print(5 + 5)") print(output)
🌐
Pythonspot
pythonspot.com › python-subprocess
Python Subprocess — Tutorial with Examples
If you start notepad.exe as a windowed app then python will not get the output. The MSDOS command similar to "cat" is "type". process = Popen(['type', 'test.py'], stdout=PIPE, stderr=PIPE)
🌐
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 - It enables Python programs to run ... run a basic command using Python Popen, we start by importing the subprocess module and then use the Popen constructor to create a new process....
🌐
Stack Abuse
stackabuse.com › pythons-os-and-subprocess-popen-commands
Python's os and subprocess Popen Commands
November 9, 2017 - The os module offers four different methods that allows us to interact with the operating system (just like you would with the command line) and create a pipe to other commands. These methods I'm referring to are: popen, popen2, popen3, and popen4, all of which are described in the following sections. The goal of each of these methods is to be able to call other programs from your Python code.
🌐
Python Module of the Week
pymotw.com › 2 › subprocess
subprocess – Work with additional processes - Python Module of the Week
$ python -u subprocess_popen3.py popen3: pass through: 'through stdin to stdout' stderr : 'to stderr\n' To direct the error output from the process to its standard output channel, use STDOUT for stderr instead of PIPE.
🌐
Better Stack
betterstack.com › community › guides › scaling-python › python-subprocess
An Introduction to Python Subprocess | Better Stack Community
In this guide, you learned how to use Python’s subprocess module to run external commands, capture output, handle errors, pass input, and manage processes with precision. From simple run() calls to advanced use of Popen, you now have the tools to integrate Python with any command-line utility.
🌐
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.)

🌐
Codegive
codegive.com › blog › subprocess_popen_and_pipe_in_python.php
Subprocess popen and pipe in python
Python handles escaping of arguments, making it safer and less prone to shell injection vulnerabilities. ... The string is passed directly to the shell. This is less safe if you're taking user input, but convenient for shell features (like wildcards, pipes, redirection) if you know the input is safe. ... # Command as a list (recommended) print("--- Command as list ---") process_list = subprocess.Popen(['echo', 'Hello', 'from', 'list'], stdout=subprocess.PIPE, text=True) output_list, _ = process_list.communicate() print(f"List command output: {output_list.strip()}")
🌐
Simplilearn
simplilearn.com › home › resources › software development › python subprocess: master external command execution
Python Subprocess: Master External Command Execution
December 15, 2025 - Learn about Python's subprocess module for executing external commands. Discover how to manage processes and handle inputs/outputs efficiently.
Address   5851 Legacy Circle, 6th Floor, Plano, TX 75024 United States
🌐
Tutorialspoint
tutorialspoint.com › python › os_popen.htm
Python os.popen() Method
import os # Using popen() to execute the 'ls' command fileStream = os.popen("ls") res = fileStream.read() print(res)
🌐
Earthly
earthly.dev › blog › python-subprocess
How to Use Python's Subprocess Module - Earthly Blog
July 11, 2023 - If there are many such subprocesses in a Python script, it would help to kill the child processes after they’ve timed out. For this, we need to use the Popen constructor to run the external command....