pip install 安装出现问题:UnicodeEncodeError: 'ascii' codec can't encode characters in position XX的解决办法

我在cmd中运行: pip install wheel时出现如下的问题 : 
这里写图片描述

解决办法如下: 
**在Python目录 Python27\Lib\site-packages 建一个文件sitecustomize.py 
里面的内容是:

import sys 
sys.setdefaultencoding('gb2312') 
 

然后重新执行命令:pip install wheel

但是有可能你还会出现这样的问题: 
这里写图片描述 
那么将sitecustomize.py 的内容改成如下所示:

import sys 
sys.setdefaultencoding('utf-8') 
 

然后再次执行命令:pip install wheel

这里写图片描述 
成功了!

附上参考链接: 
http://stackoverflow.com/questions/10561923/unicodedecodeerror-ascii-codec-cant-decode-byte-0xef-in-position-1 
https://www.v2ex.com/t/90659 
http://www.crifan.com/summary_python_unicodedecode_error_possible_reasons_and_solutions/

posted @ 2017-02-16 21:14  0xcafedaddy  阅读(311)  评论(0编辑  收藏  举报