Python ez_install : UnicodeDecodeError: 'ascii' codec can't decode byte 0xae in position 11

拈花ヽ惹草 提交于 2019-11-28 11:44:24

I met the same problem, solved it by deleting non-ASCII character in window registry "HKEY_CLASSES_ROOT\MIME\Database\Content Type" and it works.The reason is

 ctype = ctype.encode(default_encoding)  

will throw UnicodeDecodeError when it met non-ASCII characters and the program will stop.

Check this link.(http://blog.csdn.net/hugleecool/article/details/17996993).

In C:\Python27\Lib\mimetypes.py find next string

default_encoding = sys.getdefaultencoding()

replace it with

if sys.getdefaultencoding() != 'gbk':  
    reload(sys)  
    sys.setdefaultencoding('gbk')  
default_encoding = sys.getdefaultencoding()

Notice: instead 'gbk' choose your encoding.

Kyaw San Oo

In C:\Python27\Lib\mimetypes.py find next string

default_encoding = sys.getdefaultencoding()

replace it with

if sys.getdefaultencoding() != 'gbk':  
    reload(sys)  
    sys.setdefaultencoding('gbk')  
default_encoding = sys.getdefaultencoding()

Notice: instead 'gbk' choose your encoding.

The above answer satisfies my case of unicode decode error in using google app engine local web server for php and python .

shellbye

In my case, simply comment the following four line worked,

try:
    ctype = ctype.encode(default_encoding) # omit in 3.x!
except UnicodeEncodeError:
    pass

And replace UnicodeEncodeError to be UnicodeError worked.

For more info, you can check this question.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!