在Deepin Linux上通過Sublime Text 3 配置Python 開發(fā)環(huán)境

前期準(zhǔn)備工作

檢查python版本,通過pip安裝相關(guān)的插件及配置。

? tonny@tonny-pc  ~  python -V
Python 2.7.11+
? tonny@tonny-pc  ~ curl -O https://raw.github.com/pypa/pip/master/contrib/get-pip.py
? tonny@tonny-pc  ~ python get-pip.py
? tonny@tonny-pc  ~ sudo pip install pep8 pylint
? tonny@tonny-pc  ~ pylint --generate-rcfile > ~/dev/pylintrc

安裝 及 配置sublime

Package Control 安裝方法
  1.通過快捷鍵 ctrl+` 或者 View > Show Console 打開控制臺,然后粘貼相應(yīng)的 Python 安裝代碼;
  2.Sublime Text 3 安裝代碼并回車:

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())

3.重啟Sublime Text 3;
  4.如果在Perferences->package settings中看到package control這一項(xiàng),則安裝成功。
用Package Control安裝插件的方法:
按下Ctrl+Shift+P調(diào)出命令面板
輸入install 調(diào)出 Install Package 選項(xiàng)并回車,然后在列表中選中要安裝的插件。如圖:

**Pylinter.sublime-settings **配置了pylinter 插件。我使用下面的配置讓 Pyhton 在保存時(shí)自動規(guī)范,并對違反規(guī)范顯示圖標(biāo)。

{
    // Configure pylint's behavior
    "pylint_rc": "/home/tonny/dev/pylintrc",
 
    // Show different icons for errors, warnings, etc.
    "use_icons": true,
 
    // Automatically run Pylinter when saving a Python document
    "run_on_save": true,
 
    // Don't hide pylint messages when moving the cursor
    "message_stay": true
}

SublimeCodeIntel 插件
  智能提示插件,這個(gè)插件的智能提示功能非常強(qiáng)大,可以自定義提示的內(nèi)容庫,我的Python智能提示設(shè)置

{
    "Python" : {
    "python": "/usr/bin/python",
    "pythonExtraPaths": [
            "/usr/local/lib/python2.7/site-packages",
            "/usr/local/lib/python2.7/dist-packages"
        ]
    }
}

Python PEP8 Autoformat 插件

這是用來按PEP8自動格式化代碼的??梢栽诎芾砥髦邪惭b??旖萱I CTRL+SHIFT+R 自動格式化python代碼

常用配置

{
    "auto_complete": false,
    "caret_style": "solid",
    "ensure_newline_at_eof_on_save": true,
    "find_selected_text": true,
    "font_size": 11.0,
    "highlight_modified_tabs": true,
    "line_padding_bottom": 0,
    "line_padding_top": 0,
    "scroll_past_end": false,
    "show_minimap": false,
    "tab_size": 4,
    "translate_tabs_to_spaces": true,
    "trim_trailing_white_space_on_save": true,
    "wide_caret": true,
    "word_wrap": true,
}

通過CTRL+B 運(yùn)行 py文件。

import os

def main():
    for x in xrange(1, 10):
        print x

main()

如果想通過終端來運(yùn)行,可以安裝Terminal插件,相關(guān)配置如下:

{
    "terminal": "deepin-terminal",  
    "parameters": ["--working-directory","%CWD%"]
}

這樣按下Ctrl + Shift + T 后,就可以在當(dāng)前目錄下打開深度終端。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容