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

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

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 17 (6 by maintainers)

Most upvoted comments

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.

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.

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 https://github.com/magmax/python-readchar/issues/11#issuecomment-151002326 .