3

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__'] 
11
  • 1
    Can you add the full traceback to your post? Commented Sep 27, 2016 at 15:21
  • @Morgan Thrapp Hi, I've added the full Traceback. Commented Sep 27, 2016 at 15:24
  • I can reproduce this on Windows. There may be an issue with the module itself, or at least the docs. Commented Sep 27, 2016 at 15:26
  • @Morgan Thrapp, I also added the output that I get on a CentOS7 virtual machine in windows. It is pretty much the same. Commented Sep 27, 2016 at 15:27
  • Yeah, I would suggest you file a bug with the project maintainers. Someone may have a workaround (I've never used pexpect), but this is definitely a bug in their docs if nothing else. Commented Sep 27, 2016 at 15:30

1 Answer 1

2

Well, for the Windows Error I can tell you that Pexpect.spawn doesn't work on windows. This has to do something with pypi that provides some modules only on linux systems, and spawn uses one of those parts.

On Windows you have to use PopenSpawn instead.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.