How to Install ptyprocess in Python
Run a subprocess in a pseudo terminal
pip install ptyprocess
What is ptyprocess?
Run a subprocess in a pseudo terminal
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.
p = PtyProcessUnicode.spawn(['python']) p.read(20) p.write('6+6\n') p.read(20)
Quick Start
Minimal example to get started with ptyprocess:
import ptyprocess
print(ptyprocess.__version__)
Installation
pip (standard)
pip install ptyprocess
Virtual environment (recommended)
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install ptyprocess
pip3
pip3 install ptyprocess
conda
conda install -c conda-forge ptyprocess
Poetry
poetry add ptyprocess
Verify the Installation
After installing, confirm the package is available:
python -c "import ptyprocess; print(ptyprocess.__version__)"
If this prints a version number, installation succeeded. If you see a ModuleNotFoundError, see the errors section below.
Installation Errors
Common errors when installing ptyprocess with pip.
ModuleNotFoundError: No module named 'ptyprocess'
Cause: The package is not installed in the current Python environment.
Fix: Run pip install ptyprocess. If using a virtual environment, ensure it is activated first.
ModuleNotFoundError: No module named 'ptyprocess' (installed but still failing)
Cause: pip installed the package into a different Python than the one running your script.
Fix: Use python -m pip install ptyprocess to install into the interpreter you are running.
ImportError: cannot import name 'X' from 'ptyprocess'
Cause: The function or class does not exist in the installed version.
Fix: Check the version with pip show ptyprocess and upgrade with pip install --upgrade ptyprocess.
pip: command not found
Cause: pip is not in PATH or Python was not added to PATH during installation.
Fix: Try python -m pip install ptyprocess. On macOS/Linux try pip3.
PermissionError: [Errno 13] Permission denied
Cause: No write access to the system Python package directory.
Fix: Use a virtual environment, or add --user: pip install --user ptyprocess
SSL: CERTIFICATE_VERIFY_FAILED
Cause: pip cannot verify PyPI's SSL certificate — common behind corporate proxies.
Fix: Try: pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org ptyprocess
Recent Releases
| Version | Released |
|---|---|
0.7.0 latest |
2020-12-28 |
0.6.0 |
2018-06-22 |
0.5.2 |
2017-06-22 |
0.5.1 |
2016-02-02 |
0.5 |
2015-05-20 |
Manage ptyprocess
Upgrade to latest version
pip install --upgrade ptyprocess
Install a specific version
pip install ptyprocess==0.7.0
Uninstall
pip uninstall ptyprocess
Check what is installed
pip show ptyprocess