Python&pip install中出现的asciii码错误的问题

>pip install sh
Downloading/unpacking sh
Cleaning up...
Exception:
Traceback (most recent call last):
File "D:\developer\Python27\lib\site-packages\pip-1.4.1-py2.7.egg\pip\basecomm
and.py", line 134, in main
status = self.run(options, args)
File "D:\developer\Python27\lib\site-packages\pip-1.4.1-py2.7.egg\pip\commands
\install.py", line 236, in run
requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundl
e=self.bundle)
File "D:\developer\Python27\lib\site-packages\pip-1.4.1-py2.7.egg\pip\req.py",
line 1092, in prepare_files
self.unpack_url(url, location, self.is_download)
File "D:\developer\Python27\lib\site-packages\pip-1.4.1-py2.7.egg\pip\req.py",
line 1238, in unpack_url
retval = unpack_http_url(link, location, self.download_cache, self.download_
dir)
File "D:\developer\Python27\lib\site-packages\pip-1.4.1-py2.7.egg\pip\download
.py", line 621, in unpack_http_url
temp_location = os.path.join(temp_dir, filename)
File "D:\developer\Python27\lib\ntpath.py", line 108, in join
path += "\\" + b
UnicodeDecodeError: 'ascii' codec can't decode byte 0xb1 in position 9: ordinal
not in range(128)

Traceback (most recent call last):
File "D:\developer\Python27\Scripts\pip-script.py", line 9, in <module>
load_entry_point('pip==1.4.1', 'console_scripts', 'pip')()
File "D:\developer\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 "D:\developer\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 in position 34: ordinal
not in range(128)
-------------------------------------------------------------------------------------------------------



不知道是什么原因,不止是安装sh,安装Django,安装任何包都出现这个问题安装不了


解决方案:


原因是pip安装python包会加载我的用户目录,我的用户目录恰好是中文的,ascii不能编码。解决办法是: 
python目录 Python27\Lib\site-packages 建一个文件sitecustomize.py 
内容写: 
import sys 
sys.setdefaultencoding('gb2312') 
python会自动运行这个文件。


这个东西帮了我大忙了!感谢!!

原地址:http://www.v2ex.com/t/90659

 


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值