I am running CentOS7 and have installed pexpect in Python3.5. However, when I call any of the methods it is returning an error stating the attribute does not exist. Any ideas why this is occurring? I read that it could be due to a file name pexpect.py in the directory but I do NOT have a file called pexpect.py in the same directory.
$ pip3.5 freeze | grep pexpect pexpect==4.2.1 Example Code:
# This connects to the openbsd ftp site and # downloads the recursive directory listing. import pexpect child = pexpect.spawn('ftp ftp.openbsd.org') child.expect('Name .*: ') child.sendline('anonymous') child.expect('Password:') child.sendline('[email protected]') child.expect('ftp> ') child.sendline('lcd /tmp') child.expect('ftp> ') child.sendline('cd pub/OpenBSD') child.expect('ftp> ') child.sendline('get README') child.expect('ftp> ') child.sendline('bye') Error:
CentOS7 Virtual Machine Error:
/usr/local/bin/python3.5 /media/sf_PycharmProjects/MyPyScripts/Tutorials/input_cmds Traceback (most recent call last): File "/media/sf_PycharmProjects/MyPyScripts/Tutorials/input_cmds", line 4, in <module> child = pexpect.spawn('ftp ftp.openbsd.org') AttributeError: module 'pexpect' has no attribute 'spawn' Windows Error:
Traceback (most recent call last): File "C:/Users/home/PycharmProjects/PyCAT/Current_Version/SFTP/testsftp.py", line 4, in <module> child = pexpect.spawn('ftp ftp.openbsd.org') AttributeError: module 'pexpect' has no attribute 'spawn' Pexpect Dir:
>>> import pexpect >>> dir(pexpect) ['__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__']