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
1 week ago - The initial process creation itself cannot be interrupted on many platform APIs so you are not guaranteed to see a timeout exception until at least after however long process creation takes. The input argument is passed to Popen.communicate() and thus to the subprocess’s stdin.
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-subprocess-module
Python subprocess module - GeeksforGeeks
2 weeks ago - Example: Here, input is sent to a Python process and the result is captured. ... import subprocess process = subprocess.Popen( ["python"], stdin=subprocess.PIPE, stdout=subprocess.PIPE, text=True ) output, _ = process.communicate("print(5 + 5)") print(output)
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
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
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
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
🌐
DataCamp
datacamp.com › tutorial › python-subprocess
An Introduction to Python Subprocess: Basics and Examples | DataCamp
September 12, 2025 - Popen allows you to start a new process and interact with its standard input, output, and error streams. It returns a handle to the running process that can be used to wait for the process to complete, check its return code, or terminate it.
🌐
Dataquest
dataquest.io › blog › python-subprocess
Python Subprocess: The Simple Beginner's Tutorial (2023)
February 19, 2025 - In this article, we'll demonstrate how to use the subprocess module in Python to run different subprocesses during a regular Python script.
🌐
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.
Find elsewhere
🌐
Python Module of the Week
pymotw.com › 2 › subprocess
subprocess – Work with additional processes - Python Module of the Week
The Popen instance forks a new process. The new process runs os.setsid(). The new process runs exec() to start the shell. The shell runs the shell script. The shell script forks again and that process execs Python.
🌐
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.)

🌐
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 - Python Popen is a class within the subprocess module that allows us to spawn new processes, connect to their input/output/error pipes, and obtain their return codes.
🌐
Real Python
realpython.com › python-subprocess
The subprocess Module: Wrapping Programs With Python – Real Python
January 18, 2025 - You’ll also dip your toes into advanced usage of Python’s subprocess by experimenting with the underlying Popen() constructor. Source Code: Click here to download the free source code that you’ll use to get acquainted with the Python subprocess module. First off, you might be wondering why there’s a sub in the Python subprocess module name. And what exactly is a process, anyway?
🌐
Stack Abuse
stackabuse.com › pythons-os-and-subprocess-popen-commands
Python's os and subprocess Popen Commands
November 9, 2017 - The Python documentation recommends the use of Popen in advanced cases, when other methods such like subprocess.call cannot fulfill our needs. This method allows for the execution of a program as a child process.
🌐
Reddit
reddit.com › r/learnpython › how does the os.popen work()?
r/learnpython on Reddit: how does the os.popen work()?
June 19, 2017 -

The link I found: https://www.tutorialspoint.com/python/os_popen.htm, tells me that os.popen works like a pipe, but my book gives me a very confusing example:
1) open('something.py')

which is because we need an open stream. next it gives:

  h = os.popen('type something.py').read()

At this point, I'm not getting, if os.popen() acts like a pipe('|' on the terminal), then how is this supposed to be pipeing to the stream opened. and what is it piping?

🌐
Raspberry Pi Forums
forums.raspberrypi.com › board index › programming › python
How to check to see if a process is running via subprocess, and not do it if it already exists. - Raspberry Pi Forums
def stream_circle(): global process process = subprocess.Popen(["python", "stream.py", "/home/pi/laseretcher/gcode/circle.gcode", "/dev/ttyUSB0"]) if process.poll() is None: time.sleep(5) print("Lasering!") #printing_indicator() print("Finished Process") # rotate_table() def stream_uvulogo(): process = subprocess.Popen(["python", "stream.py", "/home/pi/laseretcher/gcode/uvulogo.gcode", "/dev/ttyUSB0"]) while p.poll() is None: time.sleep(5) print("Finished Process") rotate_table() def stream_stitch(): process = subprocess.Popen(["python", "stream.py", "/home/pi/laseretcher/gcode/stitch.gcode", "/dev/ttyUSB0"]) while p.poll() is None: time.sleep(5) print("Finished Process") rotate_table() Thanks for your help in advance!
🌐
Python Module of the Week
pymotw.com › 3 › subprocess
subprocess — Spawning Additional Processes
March 18, 2018 - That means when using the shell argument to Popen it will be difficult to cause the command started in the shell to terminate by sending SIGINT or SIGTERM. ... import os import signal import subprocess import tempfile import time import sys script = '''#!/bin/sh echo "Shell script in process $$" set -x python3 signal_child.py ''' script_file = tempfile.NamedTemporaryFile('wt') script_file.write(script) script_file.flush() proc = subprocess.Popen(['sh', script_file.name]) print('PARENT : Pausing before signaling {}...'.format( proc.pid)) sys.stdout.flush() time.sleep(1) print('PARENT : Signaling child {}'.format(proc.pid)) sys.stdout.flush() os.kill(proc.pid, signal.SIGUSR1) time.sleep(3)
🌐
Iditect
iditect.com › faq › python › opening-a-process-with-popen-and-getting-the-pid-in-python.html
Opening a process with Popen and getting the PID in python
You can open a process using the subprocess.Popen class in Python and get the PID (Process ID) of the spawned process.
🌐
Runebook.dev
runebook.dev › en › docs › python › library › subprocess › popen-objects
Concurrent Python Explained: When to Use Popen, and When to Switch to Executors
Solution/Best Practice Use the p.communicate() method to send input and read all output and errors from the child process. It handles the I/O streams simultaneously and efficiently to avoid deadlocks. Example Code (Anti-Pattern vs. Solution) output = p.stdout.read() p.wait() |python import subprocess p = subprocess.Popen(['long_running_cmd'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)