pip install在Windows下报错解决

报错:

Traceback (most recent call last):

File"C:Python27Python27Scriptspip-script.py", line 9, in<module>

load_entry_point('pip==1.4.1','console_scripts', 'pip')()

File"C:Python27libsite-packagespip-1.4.1-py2.7.eggpip\__init__

.py", line 148, in main

return command.main(args[1:], options)

File"C:Python27Python27libsite-packagespip-1.4.1-py2.7.eggpipasecomm

and.py", line 169, in main

text = '
'.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目录 Python27Libsite-packages 建一个文件sitecustomize.py

import sys 
sys.setdefaultencoding('gbk') 

python会自动运行这个文件

原文地址:https://www.cnblogs.com/jokerjason/p/7976031.html