181102 Python环境搭建(安装Sublime Text3)
利用Pycharm来编写、执行python代码是一个不错的选择,Pycharm的安装的确也很方便。但是偶然看到别人用Sublime Text来编写、执行代码,觉得很酷。所以自己动手搭建环境。
1. 下载Sublime Text3--->win7系统,安装在C盘(wherever you like,你高兴就好。反正容量不大)C:\Program Files\Sublime Text 3(我的路径);
2. 打开cmd命令窗口,安装Flake8
pip install flake8
3. 下载Package Control(点击Clone download下的Download ZIPx下载)--->在以下路径解压:C:\Users\Administrator\AppData\Roaming\Sublime Text 3(这个路径很容易找:打开软件--首选项(Preferences--Browse Packages)--打开目录后往后退一步就OK了)
注意:不推荐通过Preferences下面的Packges Control来安装,后续会有各种问题。
4. 安装插件:
通过快捷键:Ctrl+shift+p打开插一个输入框--->输入install--->按Enter键(窗口左下角就会出现Loading repositories)--->Loading结束后优惠弹出一个输入框(如下图10%***的那个)--->再这个输入框中输入插件名称,再按Enter键就开始安装插件了。
需要安装的插件是:SublimeLinter,SublimeLinter-flake8,Anaconda,SoDaReloaded,Zen Tabs,SublimeREPL等(安装插件后,重启生效)
5. 设置
5.1 Preferences--->Settings--->User
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 { 2 "caret_style": "solid", 3 "color_scheme": "Packages/Tomorrow Color Schemes/Tomorrow-Night.tmTheme", 4 "draw_white_space": "all", 5 "file_exclude_patterns": 6 [ 7 "*.pyc", 8 "*.pyo", 9 "*.exe", 10 "*.dll", 11 "*.obj", 12 "*.o", 13 "*.a", 14 "*.lib", 15 "*.so", 16 "*.dylib", 17 "*.ncb", 18 "*.sdf", 19 "*.suo", 20 "*.pdb", 21 "*.idb", 22 ".DS_Store", 23 "*.class", 24 "*.psd", 25 "*.db", 26 "*.sublime-workspace" 27 ], 28 "fold_buttons": false, 29 "folder_exclude_patterns": 30 [ 31 ".svn", 32 ".git", 33 ".hg", 34 "CVS", 35 "__pycache__" 36 ], 37 "font_face": "Ubuntu Mono", 38 "font_options": 39 [ 40 "directwrite", 41 "subpixel_antialias", 42 "no_bold", 43 "no_italic" 44 ], 45 "font_size": 16, 46 "highlight_line": "true", 47 "highlight_modified_tabs": true, 48 "ignored_packages": 49 [ 50 "Vintage" 51 ], 52 "indent_guide_options": 53 [ 54 "draw_active" 55 ], 56 "line_padding_bottom": 1, 57 "line_padding_top": 2, 58 "scroll_past_end": true, 59 "shift_tab_unindent": true, 60 "theme": "SoDaReloaded Dark.sublime-theme", 61 "wide_caret": "true" 62 }
5.2 Preferences--->Package Settings--->Package Control--->Setting User
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 { 2 "bootstrapped": true, 3 "in_process_packages": 4 [ 5 ], 6 "installed_packages": 7 [ 8 "Anaconda", 9 "Package Control", 10 "SideBarEnhancements", 11 "SublimeLinter", 12 "SublimeLinter-flake8", 13 "SublimeREPL", 14 "Theme - SoDaReloaded", 15 "Tomorrow Color Schemes", 16 "View In Browser", 17 "Zen Tabs" 18 ], 19 "repositories": 20 [ 21 "https://github.com/n1k0/SublimeHighlight/tree/python3", 22 "https://github.com/n1k0/SublimeHighlight/tree/python3" 23 ] 24 }
5.3 Prefereces-->Package Settings-->SublimeLinter-->Settings
改两处:把Default替换成user;添加python执行文件的路径在paths中。
5.4 Preferences--->Package Settings--->Zen Tab--->Setting User
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 { 2 "open_tab_limit":5, 3 "highlight_modified_tabs":true, 4 "show_full_path":false 5 }
5.5 Preferences--->Settings - Syntax Specific
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 "tab_size": 4, 2 "translate_tabs_to_spaces": true, 3 "trim_trailing_white_space_on_save": true, 4 "ensure_newline_at_eof_on_save": true, 5 "rulers": [ 6 72, 7 79 8 ], 9 "word_wrap": true, 10 "wrap_width": 80
6. 设置执行程序的快捷键
可以通过点击Tools-->SublimeREPL-->Python-->Python-RUN current file来执行代码,但是过于麻烦,我们可以设置快捷键F5来执行程序。
设置方法:Preferences-->Key Bindings,添加如下代码。设置好后,运行效果如下图:
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 [ 2 { 3 "keys":["f5"], 4 "caption":"SublimeREPL:Pyhton - RUN current file", 5 "command":"run_existing_window_command", 6 "args": 7 { 8 "id":"repl_python_run", 9 "file":"config\\python\\Main.sublime-menu" 10 } 11 } 12 ]