Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.

Python: Strange behaviour from pexpect

  • 17-07-2020 04:54PM
    #1
    Registered Users, Registered Users 2 Posts: 5,751 ✭✭✭


    I am using pexpect to check i am in the correct dir
        child = pexpect.spawn('ls')
        print(str(child.read()))
        child.expect("e")
    

    However it says it cannot find it despite the output of child.read() print being
    b"'~'   auto_copy_file.py   auto_upload_file.py   file   testout.txt\r\n"
    

    Not sure what is wrong. Full error below
        Error
    Traceback (most recent call last):
      File "/usr/lib/python3/dist-packages/pexpect/spawnbase.py", line 166, in read_nonblocking
        s = os.read(self.child_fd, size)
    OSError: [Errno 5] Input/output error
    


Comments

  • Registered Users, Registered Users 2 Posts: 6,964 ✭✭✭Talisman


    The dreaded "[Errno 5] Input/output error" :eek:

    It has perplexed me at times and the solutions are never the same.

    When pexpect.expect spits the dummy it's usually with an EOF or TIMEOUT exception.

    The error message you are receiving suggests it's not the provided piece of code that is the cause of the issue, it's possibly in the OS or hardware level.

    What version of Python 3 are you running and on what environment?


Advertisement