1. Geert Jansen
  2. winpexpect


Clone wiki

winpexpect / Home


WinPexpect is a port of pexpect to the Windows platform. Pexpect is a Python version of Don Libes' Expect library for TCL. WinPexpect runs 100% native on Windows using Mark Hammond's excellent pywin32 Python for Windows extensions (no Cygwin required!). At the moment winpexpect includes a modified copy of pexpect, but the goal is to get this merged upstream with pexpect and to stop this project as a separate project.

WinPexpect is open source software and is distributed under a MIT License.

Installation Instructions

WinPexpect supports Python 2.6 and higher (including Python 3.x). Earlier version of Python may work but are untested. Before you can install it you need to download and install the pywin32 extensions. Note that winpexpect includes a (slightly) modified version of pexpect and so you should not install pexpect yourself.

The easiest way to install winpexpect is via the Python Package Index.

  $ easy_install winpexpect

You can also download the source from the downloads section and then use setuptools to install:

  $ python setup.py install

WinPexpect includes unit tests. To run the tests, you need nose. Use the following command to run the tests:

  $ python setup.py test

Using WinPexpect

The API of winpexpect is identical to that of pexpect. The only difference is that you must use the class "winspawn" instead of "spawn". So:

from winpexpect import winspawn
child = winspawn('powershell')


For support, please use the winpexpect group on Google Groups.