【发布时间】:2017-12-04 17:17:13
【问题描述】:
Eclipse(和其他 IDE,例如 Pycharm/IntelliJ)似乎没有使用合适的终端来运行程序。当程序需要使用正确的标准输入/标准输出时,这可能会导致一些问题。
例如简单的python脚本
# Exit upon any keypress
import sys
import termios
import tty
fd = sys.stdin.fileno()
tty.setraw(sys.stdin.fileno())
while not sys.stdin.read(1):
pass
直接从 bash 运行时会正常运行,但从任何 IDE 运行时会失败并出现以下错误
Traceback (most recent call last):
File "/Users/anishmoorthy/Code/termserver/turst.py", line 19, in <module>
while readchar() is None:
File "/Users/anishmoorthy/Code/termserver/turst.py", line 10, in readchar
tty.setraw(sys.stdin.fileno())
File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/tty.py", line 20, in setraw
mode = tcgetattr(fd)
termios.error: (25, 'Inappropriate ioctl for device')
更一般地说,任何对tcgetattr(<stdin>) 的调用都会失败。
我想知道是否有任何插件或设置,Eclipse 或 IntelliJ,它们可以通过在适当的 bash 进程中运行脚本来修复这些错误。
IntelliJ 实际上在其运行配置选项中有一个“在输出控制台中模拟终端”复选框,它修复了这些错误,但由于某种原因,它没有注册我的输入键 - 使其或多或少无用
【问题讨论】:
标签: eclipse intellij-idea terminal console pycharm