Sunday, January 23, 2011

how to get python pexpect module on windows?

From quite a long time i was looking for a python module like "pexpect" for windows OS. I have wasted so many hours of mine to get some work around, finally what i got might help you all.

1. We can install pexpect module of python on windows . :) :)  But it requires cygwin installation.

2. Download Cygwin and install from any official site. Eg: http://cygwin.com

3. Once cygwin installation has completed, start cygwin session. (execute: cygwin.bat from installation directory or double click shortcut  of cygwin on your desktop.)

4. All windows directories will be referenced with respect to /cygdrive . Eg: D: directory will be referenced as /cygdrive/d/


5. execute following given below commands: Make sure python is installed on your system if not please install before executing given below commands.

#### assuming your python installation directory is C:/python25 ####
$ alias pythonpath=/cygdrive/c/python25/python
$ export pythonpath

6. Now check all well or not :

$ which python
/usr/local/python

#### if every thing will be ok It will return "/usr/local/python"  other wise go through steps given above and check u did all as mentioned there #############

7. Now get your pexpect.tar.gz file.

$ tar -xvzf pexpect.tar.gz
$ cd pexpect

$ python setup.py build
$ python setup.py install



8. Now you can use pexpect in your python script:

Note: you can use pexpect module on python from cygwin prompt only (For: Windows OS).

For Any Other Assistance Please write me on : jeet27.pawan@gmail.com