PyWinPTY provides pseudo-terminal support for Windows, allowing Python applications to create and communicate with console processes via input and output pipes. It leverages both the native ConPTY interface and the fallback winpty library. The current version is 3.0.3, with minor releases for dependency updates and bug fixes, and a major release (3.0.0) focusing on performance and async compatibility.
pip install pywinptyVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to spawn a Python interpreter within a pseudo-terminal, write commands to its input, and capture its output. It highlights the use of `PtyProcess.spawn()` and the `read()` method for interaction. The example includes error handling for `EOFError` and notes the `read()` method's behavior change in v3.0.0+.
Remove the `num_bytes` argument from calls to `proc.read()`. Implement custom buffering logic if only partial reads are desired.
Ensure you are using 64-bit Python. If installation fails, check PyPI for a compatible wheel. If building from source, install a stable or nightly Rust toolchain with `x86_64-pc-windows-msvc` target, ensure MSVC is installed (e.g., Visual Studio Build Tools), and `nuget.exe` is on your PATH if required by `maturin`. Alternatively, consider using `conda install pywinpty` or acquiring pre-built wheels from unofficial sources like Christoph Gohlke's collection for specific problematic versions (though this should be a last resort).
Verify `pywinpty` is correctly installed. If issues persist, try reinstalling `pywinpty` directly via `pip install pywinpty`. Ensure your Python installation is 64-bit and compatible wheels are being used.
No dependency data recorded yet.