Cannot import name 'spawn' for pexpect while using pxssh
问题 This is the code I am trying to run: from pexpect import pxssh s = pxssh.pxssh() if not s.login ('myip', 'myusername', 'mypassword'): print ("SSH session failed on login.") print (str(s)) else: print ("SSH session login successful") s.sendline ('ls -l') s.prompt() # match the prompt print (s.before) # print everything before the prompt. s.logout() The error which I am getting on running this is : Traceback (most recent call last): File "test_pexpect.py", line 1, in <module> from pexpect