当使用pip安装uwsgi时,'ascii'编解码器无法解码错误 [英] 'ascii' codec can't decode error when use pip to install uwsgi

查看:163
本文介绍了当使用pip安装uwsgi时,'ascii'编解码器无法解码错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在本教程中设置uwsgi: https://uwsgi.readthedocs .ORG / EN /最新/教程/ Django_and_nginx.html
我在virtualenv中运行 pip install uwsgi ,但是出现如下问题:

I am setting up uwsgi following this tutorial: https://uwsgi.readthedocs.org/en/latest/tutorials/Django_and_nginx.html. I run pip install uwsgi within virtualenv, but get the problem as follows:

Command /home/timyitong/superleagues/bin/python -c "import setuptools;__file__='/home/timyitong/superleagues/build/uwsgi/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-Z9h8Jn-record/install-record.txt --single-version-externally-managed --install-headers /home/timyitong/superleagues/include/site/python2.6 failed with error code 1 in /home/timyitong/superleagues/build/uwsgi
Traceback (most recent call last):
  File "/home/timyitong/superleagues/bin/pip", line 9, in <module>
    load_entry_point('pip==1.4', 'console_scripts', 'pip')()
  File "/home/timyitong/superleagues/lib/python2.6/site-packages/pip/__init__.py", line 148, in main
    return command.main(args[1:], options)
  File "/home/timyitong/superleagues/lib/python2.6/site-packages/pip/basecommand.py", line 169, in main
    text = '\n'.join(complete_log)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 54: ordinal not in range(128)

这似乎是一个解码问题,但是如何解决?我的系统环境是:

It seems like a decoding problem, but how to resolve that? My system environment is:

Ubuntu 10.04
Django==1.5.1
South==0.8.1
distribute==0.7.3
wsgiref==0.1.2

注意:由于不同的操作环境,此问题的答案可能会有所不同。 Twil的意见实际上解决了我在OS X中的问题。

推荐答案

这是一年前的问题?我来到这里。
我注意到asker是中文,和我一样。
那么也许我们面对同样的问题。
哦,对不起我的坏英语!

It's a question asked a year ago? I come here by Google. I notice that the asker is Chinese, same as me. So, maybe we face the same problem. Oh, sorry for my bad English!

我找到了正确的答案!

是因为当Python安装一些软件包时,它将检查Windows注册表,一些中文软件如Aliwangwang将gbk的值输入到HKEY_CLASSES_ROOT。所以Python不起作用。

It is because when Python installs 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.

可以这样解决:

打开C:\Python27 \Lib\ mimetypes.py与Notepad ++或其他编辑器,然后搜索default_encoding = sys.getdefaultencoding()行。
将代码添加到以上行:

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:

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

这篇关于当使用pip安装uwsgi时,'ascii'编解码器无法解码错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆