Skip to content Skip to sidebar Skip to footer

Running Wexpect On Windows

I have installed wexpect on Windows 7. Now, when I am trying to run any command, I am getting the below error. I am using MKS toolkit, so ls is a valid command. >>> impor

Solution 1:

Very late reply, but I also faced this problem recently.

Many reasons for failure or probably, wexpect.py needs modification (at least for my case)

Pl check pexpect_error.txt file generated in the same directory of wexpect.py file.

It forks 'python.exe' hence 'python.exe' must be in path (no other name of exe is permitted).

You must be in the same directory of wexpect.py (lib file name must be wexpect.py not pexpect.py) when you are executing your py script.

The cmd (with extension .exe/.com/.bat), must be working at your windows/shell command prompt . Check that (eg actually in Windows when we run 'ls', it is actually running ls.exe/com, in py script, mention as 'ls.exe')

Last but not least: In my case, console window for Window OS creation was failing (found from pexpect_error.txt), hence I changed below

line 2397, make Y coordinate of rect small instead of 70 eg 24 worked for me

Solution 2:

UPDATE

The issue has already solved in v2.3.4.


Brief:

Add .exe at the end of the executable:

>>> import pexpect
>>> pexpect.run('ls.exe')

Details:

The root cause of the problem placed in the enumerated which command (method). This method searches the executable in the filesystem. Here is the critical snippet from my wexpect:

# ...for path in pathlist:
    f = os.path.join(path, filename)
    if os.access(f, os.X_OK):
        return f
returnNone# ...

This code appends the parameter of run() as filename and returns it if it is a valid and executable path. Note, that Windows (unlike Linux) executables ends with *.exe

Post a Comment for "Running Wexpect On Windows"