python librairie winexpect不起作用

时间:2013-07-10 08:42:52

标签: python easy-install pexpect

我尝试使用winexpect librairie winexpect,但它在Windows上失败了!

>>> import pexpect
>>> pexpect.spawn(" ")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "c:\python26\lib\site-packages\winpexpect-1.5-py2.6.egg\pexpect.py", line
 429, in __init__
    self._spawn (command, args)
  File "c:\python26\lib\site-packages\winpexpect-1.5-py2.6.egg\pexpect.py", line
 527, in _spawn
    self.pid, self.child_fd = pty.fork()
 NameError: global name 'pty' is not defined

但适用于linux:

>>> import pexpect
>>> pexpect.spawn(' ')
<pexpect.spawn object at 0x7f5330c78610>

我在两个平台上安装了easy_install。

>:\Python26\Scripts\easy_install.exe winpexpect
Searching for winpexpect
Best match: winpexpect 1.5
Processing winpexpect-1.5-py2.6.egg
winpexpect 1.5 is already the active version in easy-install.pth

Using c:\python26\lib\site-packages\winpexpect-1.5-py2.6.egg
Processing dependencies for winpexpect
Finished processing dependencies for winpexpect

感谢您的帮助。

1 个答案:

答案 0 :(得分:0)

安装winexpect后,您可以这样使用它:

import winpexpect
winexpect.winspawn(' ')