pip install在Windows下报错解决

报错:

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会自动运行这个文件

posted @ 2017-12-04 10:46  JokerJason  阅读(3352)  评论(0)    收藏  举报

It's not who you are underneath, it's what you do that defines you

Brick walls are there for a reason :they let us prove how badly we want things