create-time : 2018-12-16 12:18:01
sublime text3 解决 EOFError: EOF when reading a line
问题引出
python 文件在sublime text3 中执行(Ctrl+B 执行Python 程序)。
在 input()
处报错: EOFError: EOF when reading a line
错误原因
sublime text3 默认是不能支持Python 命令行输入的、交互式代码执行,即Python 程序中出现需要命令输入、参数输入的都会出现此错误,例如 name = input()
解决方案
安装sublimeREPL
插件 , ctrl + shift + p
打开Package Control 点击或输入install package, 在弹出的窗口输入 SublimeREPL,点击即可安装。
- 运行当前Python 程序
工具(tool)–>sublimeREPL–> Python --> Python-Run current file
自定义快捷键
上述操作太麻烦,设置自己的快捷键
首选项–> 浏览插件–> SublimeREPL --> config --> Python -->打开Default.sublime-commands
查找自己需要的命令,如运行当前python文件 命令("caption": "SublimeREPL: Python - RUN current file"
,),需要的命令就是
"command": "run_existing_window_command", "args":
{
"id": "repl_python_run",
"file": "config/Python/Main.sublime-menu"
}
复制其。
sublime 标题栏–> 首选项–>按键绑定-用户
粘贴命令代码到文件中
[
{
"keys": ["f5"],//自定义快捷键
"command": "run_existing_window_command",
"args":
{
"id": "repl_python_run",
"file": "config/Python/Main.sublime-menu"
}
}
]
保存,重启sublime 即可。键入F5皆可Python- RUN current file