文章参考:http://eric.themoritzfamily.com/python-encodings-and-unicode.html
完整的错误是:
Traceback (most recent call last):
File ".\sublime_plugin.py", line 325, in run_
File ".\exec.py", line 145, in run
File ".\exec.py", line 42, in __init__
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc0 in position 9: ordinal not in range(128)
这些文章很多是有重复内容的,我主要看的是后面标*的那一篇;
这个问题的起因是配置文件目录下Packages\Default目录下的exec.py在编辑环境变量,但是环境变量中的字符集确少了ascii字符集
我的解决方案(参靠上面第6篇):
其中的Packages\Default\exec.py,打开编辑
找到第41-42行:
for k, v in proc_env.iteritems():
proc_env[k] = os.path.expandvars(v).encode(sys.getfilesystemencoding())
两种修改方案:
1、果断删掉!(你没看错,就是这样)
2、对它进行异常处理,避免它出错时停止程序运行就像这样:
for k, v in proc_env.iteritems():
try:
proc_env[k] = os.path.expandvars(v).encode(sys.getfilesystemencoding())
except UnicodeDecodeError:
print "Encoding error..."
print "VARIABLE: ", k, " : ", v
然后你在尝试对pyhon或是其他程序的编译,就会发现切正常了!