一、环境准备
1、官方网站地址
2、Windows 10
3、Sublime Text 3 + 官网购买license(Just a suggestion,$80)
购买链接,Sublime Text may be downloaded and evaluated for free, however a license must be purchased for continued use。如果资金紧张,可以搜索破解版License(建议支持正版,本文Lisence 来源于网络)。
Sublime text3 注册码
—– BEGIN LICENSE —–
sgbteam
Single User License
EA7E-1153259
8891CBB9 F1513E4F 1A3405C1 A865D53F
115F202E 7B91AB2D 0D2A40ED 352B269B
76E84F0B CD69BFC7 59F2DFEF E267328F
215652A3 E88F9D8F 4C38E3BA 5B2DAAE4
969624E7 DC9CD4D5 717FB40C 1B9738CF
20B3C4F1 E917B5B3 87C38D9C ACCE7DD8
5F7EF854 86B9743C FADC04AA FB0DA5C0
F913BE58 42FEA319 F954EFDD AE881E0B
—— END LICENSE ——
二、安装Sublime Text 3
1、双击下载的.exe文件安装,安装路径不要有中文目录
2、安装Sublime Text 3时,勾选“Add to explorer context menu”,可以在文件右键菜单添加“Open with Sublime Text”,方便使用Sublime Text打开文件。
三、配置Python环境
运行环境
1、打开Tools > Build System > New Build System..
2、点击New Build System后,会生成一个空配置文件,在这个配置文件内覆盖配置信息,本文python安装路径为“C:/Users/Administrator/AppData/Local/Programs/Python/Python36/python.exe”,(注意区分正反斜杠,请将路径换成python实际安装路径),然后按ctrl+s,将文件保存在默认路径,文件名命名为“Python3”
{
"encoding":"utf-8",
"cmd": ["C:/Users/Administrator/AppData/Local/Programs/Python/Python36/python.exe","-u","$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.python",
}
3、打开Tools > Build System,选择新建好的Python3即可
测试
1、新建test.py文件,输入简单python语句,按Ctrl+B运行
字体及字号
1、打开Preferences –>>Settings(Settings User),在右侧添加如下代码(font_face及font_size可根据个人喜好更改)
{
"color_scheme": "Packages/Color Scheme - Default/Monokai.sublime-color-scheme",
"font_face": "Consolas" ,
"font_size": 14,
"ignored_packages": [ "Vintage" ]
}
2、效果如下
四、安装Package Control(官网教程)
第一种方法:在线安装
通过快捷键[ctrl+`]或“View > Show Console”菜单打开控制台,将下面的Python代码粘贴到控制台里
import urllib.request,os,hashlib; h = '6f4c264a24d933ce70df5dedcf1dcaee' + 'ebe013ee18cced0ef93d5f746d80ef60'; 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)
注:上面代码仅适用于Sublime Text 3,如果是Sublime Text2请使用如下代码:
import urllib2,os,hashlib; h = '6f4c264a24d933ce70df5dedcf1dcaee' + 'ebe013ee18cced0ef93d5f746d80ef60'; 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://packagecontrol.io/' + 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 Text 3,如果在Perferences->package settings中能看到package control这一项,则表示安装成功。
第二种方法:手动安装
1、点击 Preferences > Browse Packages… 菜单
2、Browse up a folder and then into the Installed Packages/ folder
3、Download Package Control.sublime-package and copy it into the Installed Packages/ directory
4、Restart Sublime Text
1、通过Package Control安装其他插件
1.按下Ctrl+Shift+P调出命令面板
2.输入install 调出 Install Package
3.在列表中选中要安装的插件,或者输入插件名,根据命令面板中的过滤结果,选择要安装的插件
2、通过Package Control查看已安装的插件
1. 按下Ctrl+Shift+P调出命令面板
2. 输入"package",在下拉列表找到"Package Control: list packages",选中后回车,可以显示全部插件列表。