Sublime Text 3 配置Python3开发环境
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Sublime Text 3 配置Python3开发环境相关的知识,希望对你有一定的参考价值。
首先引出我的Python之路,我是计算机技术爱好者,打造属于自己代码编写的工具是一件很享受的事情,推荐用Sublime Text 3 ,关于ST3 找度娘最了解的咯。
1.下载
官网地址:http://www.sublimetext.com/3
2.Windows 10 安装配置Python环境
1)安装时注意打勾Add to explorer context menu,增加右键用ST3打开编辑。
2)Sublime Text 3 Version3.0,Build3143激活码:
—– BEGIN LICENSE —– TwitterInc 200 User License EA7E-890007 1D77F72E 390CDD93 4DCBA022 FAF60790 61AA12C0 A37081C5 D0316412 4584D136 94D7F7D4 95BC8C1C 527DA828 560BB037 D1EDDD8C AE7B379F 50C9D69D B35179EF 2FE898C4 8E4277A8 555CE714 E1FB0E43 D5D52613 C3D12E98 BC49967F 7652EED2 9D2D2E61 67610860 6D338B72 5CF95C69 E36B85CC 84991F19 7575D828 470A92AB —— END LICENSE ——
3)安装Package Control来管理模块插件,Ctrl+`调出ST3 控制台复制如下代码回车:
import urllib.request,os,hashlib; h = ‘7183a2d3e96f11eeadd761d777e62404‘ + ‘e330c659d4bb41d3bdf022e94cab3cd0‘; pf = ‘Package Control.sublime-package‘; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); by = urllib.request.urlopen( ‘http://packagecontrol.io/‘ + pf.replace(‘ ‘, ‘%20‘)).read(); dh = hashlib.sha256(by).hexdigest(); print(‘Error validating download (got %s instead of %s), please try manual install‘ % (dh, h)) if dh != h else open(os.path.join( ipp, pf), ‘wb‘ ).write(by)
如果在Preferences中看到package control这一项,则表明安装成功
下面安装python的一些插件:
按Ctrl+Shift+P调出Package Control的面板,输入pcip(package control:install package首字母)安装插件
3.1)Boxy Theme主题,这是我个人比较喜欢的主题
配置ST3全局:
{ "auto_find_in_selection": true, "bold_folder_labels": true, "font_face": "Monaco", "font_size": 13, "theme": "Boxy Solarized Dark.sublime-theme", "color_scheme": "Packages/Boxy Theme/schemes/Boxy Solarized Dark.tmTheme", "default_line_ending": "unix", "dpi_scale": 1.0, "draw_minimap_border": true, "ensure_newline_at_eof_on_save": true, "fade_fold_buttons": false, "highlight_line": true, "highlight_modified_tabs": true, "ignored_packages": [ "Vintage" ], "save_on_focus_lost": true, "trim_automatic_white_space": true, "trim_trailing_white_space_on_save": true, "update_check": false, "word_wrap": "true" }
3.2)SublimeCodeIntel插件,代码自动提示
配置(路径写自己的)
{ "python":{ "python":"C:/Users/HuangPiHu/AppData/Local/Programs/Python/Python36/python.exe", "pythonExtraPaths":[ "C:/Users/HuangPiHu/AppData/Local/Programs/Python/Python36", "C:/Users/HuangPiHu/AppData/Local/Programs/Python/Python36/DLLs", "C:/Users/HuangPiHu/AppData/Local/Programs/Python/Python36/Lib", "C:/Users/HuangPiHu/AppData/Local/Programs/Python/Python36/Lib/site-packages", ] } }
3.3)Pylinter插件,Python语法检查
配置
{ //Python路径 "python_path": [ "C:/Users/HuangPiHu/AppData/Local/Programs/Python/Python36/python.exe" ], //安装pylint-1.7.2的绝对路径 "pylint_path": "C:/Users/HuangPiHu/AppData/Local/Programs/Python/Python36/Lib/site-packages/pylint/lint.py", //忽略“R”、“C”提示 "ignore": ["R","C"], }
3.4)SideBarEnhancements插件,扩展侧边,不需要配置,但值得注意的是ST3打开(项目)文件夹后才有用
3.5)SublimeTmpl插件,新建以预设好的Python模板文件,快捷键:Ctrl+Alt+Shift+P
配置
{ "disable_keymap_actions": false, // "all"; "html,css" "date_format" : "%Y-%m-%d %H:%M:%S", "attr": { "author": "leopython", "email": "[email protected]", "link": "http://www.cnblogs.com/leopython/" } }
3.6)SublimeREPL插件,由于Ctrl+B运行Python文件不能输入(版本的问题吧,俺不纠结),所以安装此插件,可以解决,还有一个好处就是可以分屏调试,保留结果。
Preferences->Browse Packages->SublimeREPL->config->Python->Default.sublime-commands配置:
[ { "caption": "SublimeREPL: Python", "command": "run_existing_window_command", "args": { "id": "repl_python", "file": "config/Python/Main.sublime-menu" } }, { "caption": "SublimeREPL: Python - PDB current file", "command": "run_existing_window_command", "args": { "id": "repl_python_pdb", "file": "config/Python/Main.sublime-menu" } }, { "caption": "SublimeREPL: Python - RUN current file", "command": "run_existing_window_command", "args": { "id": "repl_python_run", "file": "config/Python/Main.sublime-menu" } }, { "command": "python_virtualenv_repl", "caption": "SublimeREPL: Python - virtualenv" }, { "caption": "SublimeREPL: Python - IPython", "command": "run_existing_window_command", "args": { "id": "repl_python_ipython", "file": "config/Python/Main.sublime-menu" } } ]
[ //SublimeREPL快捷键 {"keys": ["f5"],"command":"run_existing_window_command", "args": { "id": "repl_python_run", "file": "config/Python/Main.sublime-menu" } }, ]
3.7)Anaconda插件,Python终极插件,配置如下
{ //忽略各种空格不对, 超过80字, import的函数没有使用的提醒, "pep8_ignore": ["E501", "W292", "E303", "W391", "E225", "E302", "W293", "E402"], "pyflakes_explicit_ignore": [ "UnusedImport" ], //保存文件后自动pep8格式化 "auto_formatting": true, //库函数的提示 "enable_signatures_tooltip": true, "merge_signatures_and_doc":true, "anaconda_linting": false, }
3.8)Python PEP8 Autoformat 代码格式更正。
快捷键ctrl+shift+R.
3.9)Terminal 调出Windows的控制台,用于各种命令操作。
Terminal.sublime-settings:
{ "terminal": "C:\\\\WINDOWS\\\\system32\\\\cmd.exe", "parameters": ["/START", "%CWD%"] }
以上插件配置基本够我个人使用了,仅供学习参考。
以上是关于Sublime Text 3 配置Python3开发环境的主要内容,如果未能解决你的问题,请参考以下文章
Mac Sublime Text 3 配置Python环境及安装插件
python3代码编辑器① | Sublime Text3各操作系统安装与配置