Sublime3中使用F5快捷键运行Python文件/解决['$file_basename': [Errno 2] No such file or directory]

1) SublimeREPL 绑定F5快捷键,快速运行Python程序

Sublime3 在安装完成SublimeREPL插件后,进行键位绑定:

Preferences->按键绑定-用户,粘贴以下代码,并保存.

{"keys":["f5"], "caption": "SublimeREPL: Python - RUN current file", "command": "run_existing_window_command", "args": {"id": "repl_python_run","file": "config/Python/Main.sublime-menu"} }

2) 当点击F5程序时,右侧REPL窗口会显示执行结果,但当多次连续点击F5之后,右侧窗口会报错:

C:\Program Files\Python36\python.EXE: can't open file '$file_basename': [Errno 2] No such file or directory

***Repl Closed***

网上资料说,设置sublimeREPL的User配置项:

Preferences==>Package-Settings==>SublimeREPL==>Settings-User

{
    "default_extend_env": {"PATH": "{PATH}:YourPythonDirPath"}
}

但是其实发现是,当多次点击F5之后,当前的py文件(左侧编辑器)失去了焦点~也就是说每次F5执行之前,可以点击一下py文件.然后执行,就不会报错啦.

你可能感兴趣的:(Python)