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



13 comments:

Unknown said...

Its working fine ...

Pawan Singh said...

you can use it without cygwin session(or prompt) and it works.
Let your cygwin install directory is :
C:/cygwin

so you can use python from cygwin module as:

c:/cygwin/bin/[pythonxx].exe your_python_script.py

replace pythonxx with your python version like:
python25,python26 or python31

Unknown said...

Hi,
I tried ur commands. But i got stuck after the following command:
Subbulakshmi@DHC008 /cygdrive/c/cygwin/usr/local/bin/pexpect-2.3
$ python setup.py build
/usr/local/bin/python.exe: error while loading shared libraries: python27.dll: cannot open shared object file: No such file or directory

please guide me...

Thanks in advance

Unknown said...

Hi,
I tried ur commands and got stuck after the following:
Subbulakshmi@DHC008 /cygdrive/c/cygwin/usr/local/bin/pexpect-2.3
$ python setup.py build
/usr/local/bin/python.exe: error while loading shared libraries: python27.dll: cannot open shared object file: No such file or directory


please guide me

Unknown said...

Hi,

I followed ur commands and got stuck in the following:

Subbulakshmi@DHC008 /cygdrive/c/cygwin/usr/local/bin/pexpect-2.3
$ python setup.py build
/usr/local/bin/python.exe: error while loading shared libraries: python27.dll: cannot open shared object file: No such file or directory

Please guide me

tnx in advnce

Unknown said...

Hi,

I followed ur commands and got stuck in the following:

Subbulakshmi@DHC008 /cygdrive/c/cygwin/usr/local/bin/pexpect-2.3
$ python setup.py build
/usr/local/bin/python.exe: error while loading shared libraries: python27.dll: cannot open shared object file: No such file or directory

Please guide me

tnx in advnce

Anonymous said...

Hi,

I followed ur commands and got stuck in the following:

Subbulakshmi@DHC008 /cygdrive/c/cygwin/usr/local/bin/pexpect-2.3
$ python setup.py build
/usr/local/bin/python.exe: error while loading shared libraries: python27.dll: cannot open shared object file: No such file or directory

Please guide me

tnx in advnce

Unknown said...

Hi,

I followed ur commands and got stuck in the following:

Subbulakshmi@DHC008 /cygdrive/c/cygwin/usr/local/bin/pexpect-2.3
$ python setup.py build
/usr/local/bin/python.exe: error while loading shared libraries: python27.dll: cannot open shared object file: No such file or directory

Please guide me

tnx in advnce

Pawan Singh said...

Which python version are you using ? and your python bin directory has that dll or not ?

Unknown said...

I am now using python27. I downloaded pexpect-2.3 and have done all the steps from 1-7. Then I type python to enter the interactive mode and then type "import pexpect", but it returned with "ImportError: No module named resource
A critical module was not found. Probably this operating system does not support it. Pexpect is intended for UNIX-like operating system."
Could you help?

Unknown said...

Hi,
I am using python2.7 and I have downloaded pexpect-2.3. After steps 1-7, I type python to enter interactive mode, then type "import pexpect", it returns with "ImportError: No module named resource. A critical module was not found. Probably this operating system does not support it. Pexpect is intended for UNIX-like operating system'
Could you please help? thanks!

Pawan Singh said...

Windows changes many things with every upgrade, above steps were tested with win xp.

Anonymous said...

Hi,

After importing pexpect, I am getting this error:
Traceback (most recent call last):
File "conn.py", line 1, in
import pexpect
File "C:\Python27\lib\site-packages\pexpect.py", line 85, in
support it. Pexpect is intended for UNIX-like operating systems.""")
ImportError: No module named resource

A critical module was not found. Probably this operating system does not
support it. Pexpect is intended for UNIX-like operating systems.