Python Network Programming
上QQ阅读APP看书,第一时间看更新

Pexpect installation

Since this is the first package we will install, we will install both the pip tool with the pexpect package. The process is pretty straightforward:

sudo apt-get install python-pip #Python2
sudo apt-get install python3-pip
sudo pip3 install pexpect
sudo pip install pexpect #Python2
I am using pip3 to install Python 3 packages, while using pip to install packages in the Python 2 environment.

Do a quick to test to make sure the package is usable:

>>> import pexpect
>>> dir(pexpect)
['EOF', 'ExceptionPexpect', 'Expecter', 'PY3',

'TIMEOUT', '__all__', '__builtins__', '__cached__',
'__doc__', '__file__', '__loader__', '__name__',
'__package__', '__path__', '__revision__',
'__spec__', '__version__', 'exceptions', 'expect',
'is_executable_file', 'pty_spawn', 'run', 'runu',
'searcher_re', 'searcher_string', 'spawn',
'spawnbase', 'spawnu', 'split_command_line', 'sys',
'utils', 'which']
>>>