简体   繁体   English

使用pip和easy_install:仍然是“ UnicodeDecodeError”

[英]Using pip and easy_install: anyway “UnicodeDecodeError”

I am using Python 2.7 + Windows. 我正在使用Python 2.7 + Windows。

I wanted to install python-docx so I followed the instruction and did: 我想安装python-docx,所以我按照说明进行了:

pip install python-docx

it failed so I did: 它失败了,所以我做到了:

easy_install python-docx

both of them give error message: 他们两个都给出错误信息:

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

then according to searched results, I did: 然后根据搜索结果,我做了:

pip install –-upgrade setuptools

and

pip install –U pip

all produced the same error ("UnicodeDecodeError"). 都产生了相同的错误(“ UnicodeDecodeError”)。

How can I find what went wrong, and how can I correct it? 我如何找到问题所在,以及如何解决?

see hugleecool's answer to the question 'ascii' codec can't decode error when use pip to install uwsgi 使用pip安装 uwsgi时,请参见hugleecool对问题“ ascii”编解码器无法解码错误的答案

to add some lines above to the 在上面添加一些行

'default_encoding = sys.getdefaultencoding()' 

in file 在文件中

'C:\Python27\Lib\ mimetypes.py'

the lines are: 这些行是:

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

problem solved. 问题解决了。

I think problem is" - "this one.ASCII has very limited characters so cant decode that smybol.First open command line.Write: 我认为问题是“ - ”。这个ASCII字符非常有限,因此无法解码该smybol。首先打开命令行。写:

chcp CHCP

It will return something like: 它将返回类似:

Active code page: 857 活动代码页:857

Then write; 然后写;

chcp 1254

And try your easy-install methods.It must be work.It will change your encoding and can decode much characters than before. 尝试使用易于安装的方法,它必须可以工作,它将改变您的编码并可以解码比以前更多的字符。

Also for every case, right click on command line title-->preferences/options-->font type--> Choose "Lucida Console" and save it. 同样对于每种情况,右键单击命令行标题->首选项/选项->字体类型->选择“ Lucida Console”并保存。

Unfortunately Python 2x has too much problems with decode.Switch to 3x, an advice :-) 不幸的是,Python 2x在解码方面存在太多问题,请改用3x,这是一个建议:-)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM