Pexpect is on PyPI, and can be installed with standard tools:
pip install pexpect
This version of Pexpect requires Python 2.6 or 3.2 or above. For older
versions of Python, continue using Pexpect 2.4.
Pexpect only works on POSIX systems, where the pty module
is present in the standard library. It may be possible to run it on Windows