sublime text3上设置 python 环境

 


1. 打开Sublime text 3 安装package control

2. 安装 SublimeREPL

Preferences -> package control 或者Ctrl+shift+p

键入 install packages稍等片刻后

键入 SublimeREPL 安装即可。(由于种种原因,在国内直接通过package control安装插件时,一定概率会出现网络异常。可以FQ解决,或者等网络正常后安装。)

 


 

3.设置安装路径

在 Preferences -> Package Settings -> SublimeREPL -> Settings - User里面保存自己安装Python的路径就好了,比如:

 

{
"default_extend_env": {"PATH":"C:\\python32\\"},  # 替换 "C:\\python32\\" 为自己的安装路径即可。
}

 

 


 

4.键位绑定

安装完成之后,可以通过 Tools -> SublimeREPL -> Python -> Python - RUN current file 这样的方式来启动解释器运行程序。或者Tools -> SublimeREPL -> Python -> Python 启动交互式解释器。

但是每次都这样特别的繁琐。最好有一个一键式启动。

以下方式可以绑定 f1 键为交互式解释器, f2 键为直接编译当前文件。

进入Preferences -> Key Bindings-User

[
    {"keys":["f1"],
    "caption": "SublimeREPL: Python",
    "command": "run_existing_window_command", "args":
    {"id": "repl_python",
    "file": "config/Python/Main.sublime-menu"}},

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

 


 

5.使用

按F1键会出现交互式解释器

按F2键虎出现执行结果


 

参考:1.知乎https://www.zhihu.com/question/22904994/answer/87527103

posted @ 2018-05-03 13:46  dongye95  阅读(5626)  评论(0编辑  收藏  举报