pexpect/ptyprocess

Run a subprocess in a pseudo terminal

Python

240

156 commits

updated Aug 26, 2026

See the code

README

Launch a subprocess in a pseudo terminal (pty), and interact with both the
process and its pty.

Sometimes, piping stdin and stdout is not enough. There might be a password
prompt that doesn't read from stdin, output that changes when it's going to a
pipe rather than a terminal, or curses-style interfaces that rely on a terminal.
If you need to automate these things, running the process in a pseudo terminal
(pty) is the answer.

Interface:

.. code:: python

    from ptyprocess import PtyProcessUnicode
    p = PtyProcessUnicode.spawn(['python'])
    p.read(20)
    p.write('6+6\n')
    p.read(20)

Not written in Markdown, so it's shown here as plain text — view it formatted on GitHub.

pexpect/ptyprocess

Run a subprocess in a pseudo terminal

Python

240

156 commits

updated Aug 26, 2026

See the code

README

Launch a subprocess in a pseudo terminal (pty), and interact with both the
process and its pty.

Sometimes, piping stdin and stdout is not enough. There might be a password
prompt that doesn't read from stdin, output that changes when it's going to a
pipe rather than a terminal, or curses-style interfaces that rely on a terminal.
If you need to automate these things, running the process in a pseudo terminal
(pty) is the answer.

Interface:

.. code:: python

    from ptyprocess import PtyProcessUnicode
    p = PtyProcessUnicode.spawn(['python'])
    p.read(20)
    p.write('6+6\n')
    p.read(20)

Not written in Markdown, so it's shown here as plain text — view it formatted on GitHub.

Project health

Overall

3.6/10

Maintained

1/10

Code review

7/10
OpenSSF Scorecard

Latest release

0.7.0 · Dec 28, 2020

Releases this year

0

Significant stargazers

Tom Ballinger

554 followers · starred Apr 2015

Daniel Holth

104 followers · starred Jun 2022

acheronfail

66 followers · starred Jan 2024

Shuai Lin

124 followers · starred May 2017