sublime text3 很好的文本编辑器,用来运行小脚本很适合。介绍一下如何配置python使用环境,sublime里面支持python最好的代码提示、参数不全等功能是anaconda插件。
1) 下载sublime text3
https://www.sublimetext.com/3
2) 安装包插件
打开sublime text3 , 按Shift+ctrl+P, 进入命令界面,输入install package control,安装这个插件。
3) 安装anaconda插件
按shift+ctrl+P,进入package control, 等一会儿在弹出的窗口内搜索anaconda插件,安装。
4)配置anaconda插件
进入preference>package settings>anaconda>settings default
改变python的解释器的路径,以及可以修改错误提示的样式等。
下面这几个参数可以修改一下,不然错误提示比较难看,外面一堆框框。 各个参数代表了什么意思,可以看上面的注释。
/*
If 'outline' (default), anaconda will outline error lines."anaconda_linter_phantoms": false,
5)sublime repl 插件
这个可以更加友好的开启ipython等。直接在package control里面下载安装。
在preference>browse packages>sublimeREPL>config>python>Main.sublime-menu, 打开编辑python的interpreter:
"children":[
{"command": "repl_open",
"caption": "Python",
"id": "repl_python",
"mnemonic": "P",
"args": {
"type": "subprocess",
"encoding": "utf8",
"cmd": ["D:/ProgramFiles/anaconda3/python", "-i", "-u"],
"cwd": "$file_path",
"syntax": "Packages/Python/Python.tmLanguage",
"external_id": "python",
"extend_env": {"PYTHONIOENCODING": "utf-8"}
}
},
cmd这一行里的python路径替换为自己本地所在的python路径,注意是所有的。
6)sublime REPL快捷键设置
可以参考如下设置,分别设置了python调试,运行文件,python shell, 系统cmd等快捷键。
[
{"keys": ["ctrl+f5"],
"caption": "SublimeREPL: Python - PDB current file",
"command": "run_existing_window_command","args":
{
"id": "repl_python_pdb",
"file": "config/Python/Main.sublime-menu"
}
},{"keys":["f5"],
"caption": "SublimeREPL: Python - RUN current file",
"command": "run_existing_window_command", "args":
{
"id": "repl_python_run",
"file": "config/Python/Main.sublime-menu"
}
},{"keys":["f6"],
"caption": "SublimeREPL: Python",
"command": "run_existing_window_command", "args":
{
"id": "repl_python",
"file": "config/Python/Main.sublime-menu"
}
},{"keys":["f7"],
"caption": "SublimeREPL: Shell",
"command": "run_existing_window_command", "args":
{
"id": "repl_shell",
"file": "config/Shell/Main.sublime-menu"
}
},{"keys":["ctrl+shift+f5"],
"caption": "SublimeREPL: Python - IPython",
"command": "run_existing_window_command", "args":
{
"id": "repl_python_ipython",
"file": "config/Python/Main.sublime-menu"
}
}
]
配置好之后,就可以发现已经有了文档提示,代码补全、参数填充等功能,十分方便。