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

I'm getting the following error on Pycharm 2019.1.1. OS ubuntu 16.04.


Steps to reproduce:



import sys
from termios import tcflush, TCIFLUSH

tcflush(sys.stdin, TCIFLUSH)





/usr/bin/python3.5 /home/ubuntu/Desktop/pycharm-community-2019.1.1/helpers/pydev/ --multiproc --qt-support=auto --client --port 42789 --file /home/ubuntu/.../
Connected to pydev debugger (build 191.6605.12)
pydev debugger: process 14956 is connecting

Traceback (most recent call last):
File "/home/ubuntu/Desktop/pycharm-community-2019.1.1/helpers/pydev/", line 1741, in <module>
File "/home/ubuntu/Desktop/pycharm-community-2019.1.1/helpers/pydev/", line 1735, in main
globals =['file'], None, None, is_module)
File "/home/ubuntu/Desktop/pycharm-community-2019.1.1/helpers/pydev/", line 1135, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "/home/ubuntu/Desktop/pycharm-community-2019.1.1/helpers/pydev/_pydev_imps/", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/home/ubuntu/.../", line 4, in <module>
tcflush(sys.stdin, TCIFLUSH)
termios.error: (25, 'Inappropriate ioctl for device')
We've got an error while stopping in post-mortem: <class 'KeyboardInterrupt'>

Process finished with exit code 1


Comment actions Permalink


I think the issue is most likely not related to IDE, and you should also try asking termios developers/community.

You can confirm this by running your code outside of IDE, using system terminal and the same interpreter.

Comment actions Permalink


I have the same problem.
In terminal its work fine. 
I think pycharm cant get access to ioctl.

Comment actions Permalink

In the terminal it works. This only reproduces within Pycharm.

It seems related to this issue:

Which was fixed with an update to python plugin. Are these two issues related?

Comment actions Permalink

I've reproduced the issue, seems I was wrong and it's indeed IDE-specific.

Reproduced even without debugger, just by running the code in IDE vs terminal - only IDE produce the error.

In my case the following solution worked - in run configuration, enable option "Emulate terminal in output console"

Comment actions Permalink

Thanks for looking into it. Is there a global fix / setting to resolve this issue? Seems burdensome to having to enable "Emulate terminal in output console" for every run config.

Comment actions Permalink

You don't have to enable it for every config, you can enable the option in run configuration template, and it will be enabled for all configurations created after that.

Comment actions Permalink

I've been working with the "emulate terminal" workaround for the last several days. It has other drawbacks: when exiting, the emulated terminal does not go through the normal exit procedure as Ctrl+C (raising a keyboard exception). Instead, it exits abruptly.

What is a proper fix to be able to support ioctl in non-emulated terminal?

Comment actions Permalink

Termios works only in terminal environment, which is not the case in non-emulated terminal. 

You can also try another workaround using pseudo-terminal utilities (

For example this suggestion:

I don't think there is a 'proper' way to go about it. Maybe someone else will give a better suggestion...


Please sign in to leave a comment.