0

I am using Python 2.7 + Windows.

I wanted to install python-docx so I followed the instruction and did:

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").

How can I find what went wrong, and how can I correct it?

halfer
  • 19,824
  • 17
  • 99
  • 186
Mark K
  • 8,767
  • 14
  • 58
  • 118

2 Answers2

1

see hugleecool's answer to the question 'ascii' codec can't decode error when use pip to install uwsgi

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.

Community
  • 1
  • 1
Mark K
  • 8,767
  • 14
  • 58
  • 118
0

I think problem is" - "this one.ASCII has very limited characters so cant decode that smybol.First open command line.Write:

chcp

It will return something like:

Active code page: 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.

Unfortunately Python 2x has too much problems with decode.Switch to 3x, an advice :-)

GLHF
  • 3,835
  • 10
  • 38
  • 83