- 安装Python
- 下载pexpect模块:https://pypi.python.org/pypi/pexpect/#downloads
- 解压后在目录下运行:python ./setup.py install (必须是root权限)
如果没有使用root权限,你只需要把lib的路径放入sys.path,这样便可以使用pexpect
import syssys.path.append(‘pexpect-4.2.1/build/lib‘)
- 确认是否安装成功
>>>import pexpect>>>dir(pexpect)>>>[‘EOF‘, ‘ExceptionPexpect‘, ‘Expecter‘, ‘PY3‘, ‘TIMEOUT‘, ‘__all__‘, ‘__builtins__‘, ‘__doc__‘, ‘__file__‘, ‘__name__‘, ‘__package__‘, ‘__path__‘, ‘__revision__‘, ‘__version__‘, ‘exceptions‘, ‘expect‘, ‘is_executable_file‘, ‘searcher_re‘, ‘searcher_string‘, ‘split_command_line‘, ‘sys‘, ‘utils‘, ‘which‘]
时间: 2024-10-19 13:36:53