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:
```
# test.py
import sys
from termios import tcflush, TCIFLUSH
tcflush(sys.stdin, TCIFLUSH)
```
Errors:
```
/usr/bin/python3.5 /home/ubuntu/Desktop/pycharm-community-2019.1.1/helpers/pydev/pydevd.py --multiproc --qt-support=auto --client 127.0.0.1 --port 42789 --file /home/ubuntu/.../test.py
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/pydevd.py", line 1741, in <module>
main()
File "/home/ubuntu/Desktop/pycharm-community-2019.1.1/helpers/pydev/pydevd.py", line 1735, in main
globals = debugger.run(setup['file'], None, None, is_module)
File "/home/ubuntu/Desktop/pycharm-community-2019.1.1/helpers/pydev/pydevd.py", 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/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/home/ubuntu/.../test.py", 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
```
Please sign in to leave a comment.
Hi,
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.
Hello
I have the same problem.
In terminal its work fine.
I think pycharm cant get access to ioctl.
In the terminal it works. This only reproduces within Pycharm.
It seems related to this issue: https://youtrack.jetbrains.com/issue/PY-21566#comment=27-1742809
Which was fixed with an update to python plugin. Are these two issues related?
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"
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.
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.
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?
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 (https://docs.python.org/2/library/pty.html)
For example this suggestion: https://stackoverflow.com/a/32276648/6718686
I don't think there is a 'proper' way to go about it. Maybe someone else will give a better suggestion...
Hi, It's has been a while and I ran into the same issue. I managed to fix it using the Emulate checkbox under Execution:
The "Emulate terminal in output console" just stopped working for me in PyCharm Professional 2022.3. It used to work in 2022.2.3 for sure.
I'm using macOS Ventura 13.1 (M1) if that helps somehow.