标签:2.7 pos erro ascii 默认 can sci back set
报错:
Traceback (most recent call last):
File"C:\Python27\Python27\Scripts\pip-script.py", line 9, in<module>
load_entry_point(‘pip==1.4.1‘,‘console_scripts‘, ‘pip‘)()
File"C:\Python27\lib\site-packages\pip-1.4.1-py2.7.egg\pip\__init__
.py", line 148, in main
return command.main(args[1:], options)
File"C:\Python27\Python27\lib\site-packages\pip-1.4.1-py2.7.egg\pip\basecomm
and.py", line 169, in main
text = ‘\n‘.join(complete_log)
UnicodeDecodeError: ‘ascii‘ codec can‘t decode byte 0xb1 inposition 34: ordinal
not in range(128)
原因:
Windows的cmd环境默认为GBK编码,pip默认用UTF-8编码。
但是在Linux和Mac中,terminal环境默认的是UTF-8编码,所以不会报错。
解决方案:
python目录 Python27\Lib\site-packages 建一个文件sitecustomize.py
import sys
sys.setdefaultencoding(‘gbk‘)
python会自动运行这个文件
标签:2.7 pos erro ascii 默认 can sci back set
原文地址:http://www.cnblogs.com/jokerjason/p/7976031.html