Solution for UnicodeDecodeError: 'ascii' codec can't decode byte 0xb0 in position 1: ordinal not in range(128)

ZZ: https://bitbucket.org/pypa/setuptools/issue/127/unicodedecodeerror-when-install-in-windows

HELLO! I come here by Google. I notice that the asker is a Chinese, the same to me. So, maybe we face the same problem. Then I register this website. Oh, sorry for my bad English!

I HAVE FIND THE RIGHT ANSWER!

It is because when Python install some packages, it will check the Windows Registry, some Chinese software like Aliwangwang import 'gbk' value to the HKEY_CLASSES_ROOT. So Python doesn't work.

It can be solved like this:

open C:\Python27\Lib\ mimetypes.py with Notepad ++ or other editor, then search the line " default_encoding = sys.getdefaultencoding()". add codes to the line above like this:

1 if sys.getdefaultencoding() != 'gbk': 
2     reload(sys)
3     sys.setdefaultencoding('gbk')
4 default_encoding = sys.getdefaultencoding()

 

简单来说,就是有些国内软件修改注册表导致python无法安装库,要改下lib目录下的代码。

posted @ 2014-04-19 17:11  DuSizhong  阅读(335)  评论(0编辑  收藏  举报