Python中Sublime text环境配置

首先去官网上下载对应的sublime text软件:

http://www.sublimetext.com/

我自己下载的是2.0版本:

接着是设置sublime text,安装需要用的插件,插件的地址是:https://sublime.wbond.net/

1)安装packet control,这个插件可以方便的安装和卸载插件,因此首先安装。安装步骤是先打开编辑器,在view----show console,接着输入下面的代码,单击回车。

sublime text2输入下面的:

import urllib2,os,hashlib; h = '7183a2d3e96f11eeadd761d777e62404' + 'e330c659d4bb41d3bdf022e94cab3cd0'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); os.makedirs( ipp ) if not os.path.exists(ipp) else None; urllib2.install_opener( urllib2.build_opener( urllib2.ProxyHandler()) ); by = urllib2.urlopen( 'http://sublime.wbond.net/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); open( os.path.join( ipp, pf), 'wb' ).write(by) if dh == h else None; print('Error validating download (got %s instead of %s), please try manual install' % (dh, h) if dh != h else 'Please restart Sublime Text to finish installation')

sublime text3输入下面的:

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://sublime.wbond.net/' + 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)

具体网址如下:https://sublime.wbond.net/installation#st2

单击回车后,console中会提示重启编辑器。这样就安装成功了

2)SublimeCodeIntel

为部分语言增强自动完成功能,包括了Python。这个插件同时可以让你跳转到符号定义的地方,通过按住alt键并点击符号。非常方便。

安装开始:

打开编辑器,通过Ctrl+Shift+P,打开Command Palette...。也可以通过点击菜单Tools---Command Platee打开。

在打开的窗口中输入Package Control:Install找到安装的命令,单击回车:

然后输入sublimecodeintel,敲击回车,插件开始自动安装。下面的状态条可以看到:

安装完成后会在编辑器中自动打开一个标签。

 3)sublimeREPL

这个插件是用于运行Python中带有input和raw_input使用的。说实话,这个功能做的不是很好,用着不方便,我自己是通过在cmd窗口中运行脚本来使用,一般不用这个功能。这个功能目前使用如下:

代码如下:

#/usr/bin/env python
#-*- encoding: utf-8 -*- 
def sublimetext():
	inputVal = raw_input("now input the parameter:")
	print "you inputed parameter is "+ inputVal

if __name__ == "__main__":
	sublimetext()
然后直接Ctrl+B是无法运行的,报错如下: 这种方式应该如下运行,在菜单中:Tools----SublimeREPL-----Python----Python -RUN current file执行: 我个人认为sublime还是简单写写Python程序即可,重要的开发还是需要eclipse+pydev最好。

猜你喜欢

转载自moxuan424.iteye.com/blog/2066043