Sublime 配置 Python 开发环境

2017-01-14  本文已影响0人  找个清静的地方

Sublime Text 3 作为 Python 的开发环境,需要提供两个功能:代码提示和 REPL,这两个功能可以通过安装 Package 来实现。安装过程如下:

import urllib.request,os,hashlib; h = 'df21e130d211cfc94d9b0905775a7c0f' + '1e3d39e33b79698005270310898eea76'; 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)
"Python": {
    "python": "C:/Python27/python.exe",
    "codeintel_scan_extra_dir": [
        "C:/Python27/Lib",
        "C:/Python27/Lib/site-packages"
    ],
    "codeintel_scan_files_in_project": true,
    "codeintel_selected_catalogs": []
},

Mac 平台下,添加如下内容:

"Python": {
    "python": "C:/Python27/python.exe",
    "codeintel_scan_extra_dir": [
        "/Applications/Sublime Text.app/Contents/MacOS",
        "~/Library/Application Support/Sublime Text 3/Packages/SublimeCodeIntel/arch",
        "~/Library/Application Support/Sublime Text 3/Packages/SublimeCodeIntel/libs",
        "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7",
        "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages"            
    ],
    "codeintel_scan_files_in_project": true,
    "codeintel_selected_catalogs": []
},

这个工具初次使用,不是很稳定,状态栏经常会有些错误提示,但写代码时还是可以正常工作的。

[ 
    { "keys": ["f5"], "command": "repl_transfer_current", "args": {"scope": "file"}}
]

SublimeREPL 在使用上有一些技巧,首选通过 View -> Layout -> Columns: 2 把 Sublime 设置成两列模式,然后 Tools -> SublimeREPL -> Python ->Python 在右列显示 Python REPL,这时在左列中打开的 Python 脚本,按 F5 即可在右列显示运行结果,并可进行交互编程。

上一篇下一篇

猜你喜欢

热点阅读