1

i'm trying to use wexpect on windows machine, and facing issues in the very basic operations. i'm running the following command:

import wexpect
child = wexpect.spawn('cmd.exe')
child.send('dir')

and getting the following error:

C:\Users\Administrator\PycharmProjects\testProject\venv\Scripts\python.exe 
C:/Users/Administrator/PycharmProjects/testProject/test.py
Traceback (most recent call last):
File "C:/Users/Administrator/PycharmProjects/testProject/test.py", line 3, in <module>
child.send('dir')
File "C:\Users\Administrator\PycharmProjects\testProject\venv\lib\site-packages\wexpect.py", line 
1810, in send
c = self.wtty.write(s)
File "C:\Users\Administrator\PycharmProjects\testProject\venv\lib\site-packages\wexpect.py", line 
2128, in write
wrote = self.__consin.WriteConsoleInput(records)
**pywintypes.error: (6, 'WriteConsoleInput', 'The handle is invalid.')**

Process finished with exit code 1

please advise

betontalpfa
  • 3,454
  • 1
  • 33
  • 65
Moish
  • 11
  • 1

1 Answers1

-1

It seems you are trying to use wexpect from Pycharm, which is not supported right now.

Please run your code outside from your IDE (from a CMD).

betontalpfa
  • 3,454
  • 1
  • 33
  • 65