利用Pycharm來編寫、執行python代碼是一個不錯的選擇,Pycharm的安裝的確也很方便。可是偶然看到別人用Sublime Text來編寫、執行代碼,以爲很酷。因此本身動手搭建環境。html
1. 下載Sublime Text3--->win7系統,安裝在C盤(wherever you like,你高興就好。反正容量不大)C:\Program Files\Sublime Text 3(個人路徑);python
2. 打開cmd命令窗口,安裝Flake8git
pip install flake8github
3. 下載Package Control(點擊Clone download下的Download ZIPx下載)--->在如下路徑解壓:C:\Users\Administrator\AppData\Roaming\Sublime Text 3(這個路徑很容易找:打開軟件--首選項(Preferences--Browse Packages)--打開目錄後日後退一步就OK了)bootstrap
注意:不推薦經過Preferences下面的Packges Control來安裝,後續會有各類問題。windows
4. 安裝插件:app
經過快捷鍵:Ctrl+shift+p打開插一個輸入框--->輸入install--->按Enter鍵(窗口左下角就會出現Loading repositories)--->Loading結束後優惠彈出一個輸入框(以下圖10%***的那個)--->再這個輸入框中輸入插件名稱,再按Enter鍵就開始安裝插件了。ide
須要安裝的插件是:SublimeLinter,SublimeLinter-flake8,Anaconda,SoDaReloaded,Zen Tabs,SublimeREPL等(安裝插件後,重啓生效)svn
5. 設置ui
5.1 Preferences--->Settings--->User
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
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
1 { 2 "open_tab_limit":5, 3 "highlight_modified_tabs":true, 4 "show_full_path":false 5 }
5.5 Preferences--->Settings - Syntax Specific
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,添加以下代碼。設置好後,運行效果以下圖:
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 ]