如何解决Windows 10 下 sublime text编辑器 package control 安装失败的问题

来源:互联网 发布:计算机技术与软件 证书 编辑:程序博客网 时间:2024/05/19 23:11
Win10下安装sublime后,再安装package control 总是失败,网上搜了也没有可行的教程。本着对sublime text的热爱,我个人倒腾了好几天,终于解决了这个问题,现在将方法分享给大家。

1.打开hosts文件,添加如下一行,并保存。

50.116.34.243    sublime.wbond.net

2.去package control 官网,复制对应版本的package control安装代码。附在下面:

sublime text 2:

import urllib2,os,hashlib; h = '2915d1851351e5ee549c20394736b442' + '8bc59f460fa1548d1514676163dafc88'; 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:

import urllib.request,os,hashlib; h = '2915d1851351e5ee549c20394736b442' + '8bc59f460fa1548d1514676163dafc88'; 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)

3.打开sublime,按 ctrl+~,打开console界面,或者view>show console,复制对应的代码,回车,稍等即可。

1 0
原创粉丝点击