sublime搭建python开发环境
- 插件包管理器安装
键入:control+`
粘贴:
import urllib.request,os;
pf =\'Package Control.sublime-package\';
ipp = sublime.installed_packages_path();
urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler())); open(os.path.join(ipp, pf),\'wb\').write(urllib.request.urlopen(\'http://sublime.wbond.net/\'+ pf.replace(\' \',\'%20\')).read())
- 空格显示
Preferences->Settings-User 增加一项:
"draw_white_space":"all"
- 插件安装&推荐插件
键入:command+shift+P -> install package ,输入包名
- SublimeREPL:用于运行和调试一些需要交互的程序(E.G. 使用了Input()的程序)
-
Anaconda: python代码提示加代码检查
- 配置tab为4个空格
Preferences -> Settings-User
"tab_size":4,
"translate_tabs_to_spaces": true,
- Anacoda下配置virtualenv
- 按pep8编码格式:contrl+alt+r
- 搭建virtualenv:
在项目文件(*.sublime-project)下增加下面代码,如果没有文件,可以通过Project->Save Project创建,先清空,然后添加内容:
"settings":
{
"python_interpreter":"$venv/Scripts/python"
#linux环境下可能为"$venv/bin/python" 具体视python执行文件而定
#$venv为自己创建virtualenv环境目录
}
完整内容为:
{
"build_systems":
[
{
"file_regex": "^[ ]*File \\"(...*?)\\", line ([0-9]*)",
"name": "Anaconda Python Builder",
"selector": "source.python",
"shell_cmd": "\"/Users/liuyongzhi/Desktop/MyProject/FlaskStudy/venv/bin/python\" -u \"$file\""
}
],
"folders":
[
{
"path": "."
}
],
"settings":
{
"python_interpreter": "/Users/liuyongzhi/Desktop/MyProject/FlaskStudy/venv/bin/python"
}
}
- 添加默认文件头:
安装插件:SublimeTmpl
生成快捷键:ctrl+alt+shift+P
修改模板文件: