Skip to content

termios.error: (25, 'Inappropriate ioctl for device') #11

Closed

Description

@chinmaya-n

Greetings!

When I try to run the program below, It gives Error as in the title.
Image is here: http://imgur.com/9no96dh

import readchar

while True:
    print "Press 'A' to Start the recording"
    print "      'Z' to Stop the recording"
    print "      'Enter' to quit the program..."

    # Read a key
    key = readchar.readkey()
    if(key == 'A'):
        print "Started Recording..."
    elif(key == 'Z'):
        print "Stopped Recording..."
    elif(key == '\r'):
        print "Exiting..."
        break
    else:
        print "Please Use only allowed keys: A, Z, Enter!" 

I tried to do just run readchar.readkey() in python console, It worked fine there. But when I tried to do it as above, this error occurred. Any help will be greatly appreciated.

Note: I'm on Ubuntu Gnome x86_64. Kernel: 3.19.* v. Using Python 2.7.

Thanks & Regards,
inblueswithu

Activity

  1. magmax commented on Oct 24, 2015

    @magmax
    Owner

    which version are you using? Please, use version 0.7. It is the only one I assure that works, because I tried to change my mind in order to support other things... And it didn't work.

    https://pypi.python.org/pypi/readchar

    Thank you!

  2. chinmaya-n commented on Oct 24, 2015

    @chinmaya-n
    Author

    I installed using pip. http://imgur.com/LswwHag. You can see that my version is 0.7. readchar-0.7.dist-info

  3. techgnosis commented on Oct 25, 2015

    @techgnosis

    I'm having the same bug with readchar 0.7

  4. chinmaya-n commented on Oct 25, 2015

    @chinmaya-n
    Author

    @techgnosis Can you please try to run my program in your PC and check if its the same error for you?

  5. magmax commented on Oct 25, 2015

    @magmax
    Owner

    Well... first of all, use readchar.keys.ENTER instead of \r. But this is not going to fix the problem.

    I ran it in my machine (Python 2.7.10, virtualenv 13.1.2-2, readchar 0.7, ArchLinux, Awesome wm) with no problem.

    How could I reproduce it?

  6. magmax commented on Oct 25, 2015

    @magmax
    Owner

    Ok. I have it.

    Running it with thunar, it returns the error::

    termios.error: (25, 'Inappropriate ioctl for device')
    

    this is because I'm trying to get the terminal settings but it is not running in a terminal environment.

    I'm not sure about a good fix for this, but forcing it to be run in a terminal. I will investigate further more.

  7. techgnosis commented on Oct 25, 2015

    @techgnosis

    That makes sense. I was running it in PyCharm. I didn't try to run it in
    the terminal..

    On Sun, Oct 25, 2015 at 2:44 PM, Miguel Ángel García <
    notifications@github.com> wrote:

    Ok. I have it.

    Running it with thunar, it returns the error::

    termios.error: (25, 'Inappropriate ioctl for device')

    this is because I'm trying to get the terminal settings but it is not
    running in a terminal environment.

    I'm not sure about a good fix for this, but forcing it to be run in a
    terminal. I will investigate further more.

    —
    Reply to this email directly or view it on GitHub
    #11 (comment)
    .

  8. chinmaya-n commented on Oct 26, 2015

    @chinmaya-n
    Author

    @magmax You are right. I now ran the program in a terminal and it worked great! I have been trying to run it from WingIDE.

  9. techgnosis commented on Oct 26, 2015

    @techgnosis

    Worked for me too. Thanks guys

    On Sun, Oct 25, 2015 at 7:08 PM, inblueswithu notifications@github.com
    wrote:

    @magmax https://github.com/magmax You are right. I tried to run the
    program in the terminal and it worked great! I have been trying to run it
    from WingIDE.

    —
    Reply to this email directly or view it on GitHub
    #11 (comment)
    .

  10. magmax commented on Oct 26, 2015

    @magmax
    Owner

    So nothing more is required and this issue can be closed.

    By the way... Maybe this other library can help you: https://github.com/magmax/python-inquirer

    I wrote python-readchar just to create it. Here you are more examples: http://python-inquirer.readthedocs.org/en/latest/examples.html

  11. chinmaya-n commented on Oct 27, 2015

    @chinmaya-n
    Author

    It seems my requirement is out of scope for this library (as you are concentrating with in terminal only, but not from any other IDEs or non terminal executions). I think you can close it.

    Thank you all!

  12. magmax commented on Oct 27, 2015

    @magmax
    Owner

    I'm afraid yes. Maybe you can use pty or https://github.com/pexpect/ptyprocess in order to make it work in a non-terminal environment.

    Thank you anyways.

  13. chinmaya-n commented on Oct 28, 2015

    @chinmaya-n
    Author

    ThankYou. ptyprocess is interesting.

  14. mehditlili commented on Jun 1, 2018

    @mehditlili

    This would be useful if it works in IDE, trying to debug some code using the IDE's debugger but this error won't let me do it.

  15. ypchan commented on Jul 16, 2020

    @ypchan

    Hi, guys, Do you solve the problem? I got the same exception when I run the following code:
    `

    code line in script

    width = os.get_terminal_size().columns

    run

    ../bin/normalizer.py input.tsv out.tsv 1> log 2> error

  16. kwesolowski commented on Feb 7, 2022

    @kwesolowski

    For future self and similar - might be also an issue if you pass sth "defintiely not being tty", i.e. I saw it when we used local file by accident.

  17. fleytman commented on Jul 14, 2022

    @fleytman
    Contributor

    Partly resolution for pycharm https://intellij-support.jetbrains.com/hc/en-us/community/posts/360003383619/comments/6589796593042 (but readkey on macos can't read shift+tab and etc)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions