Python ez_install: UnicodeDecodeError: codec 'ascii' cannot decode byte 0xae at position 11

Getting error while trying to install ez_install, a 64-bit Windows 7 machine with fresh Python 2.7. Any ideas?

Installing Setuptools
Traceback (most recent call last):
  File "setup.py", line 17, in 
    exec (init_file.read (), command_ns)
  File "", line 8, in 
  File "c: \ users \ namar \ appdata \ local \ temp \ tmp1tanvy \ setuptools-2.1 \ setuptools \ __
init__.py ", line 11, in 
    from setuptools.extension import Extension
  File "c: \ users \ namar \ appdata \ local \ temp \ tmp1tanvy \ setuptools-2.1 \ setuptools \ ex
tension.py ", line 5, in 
    from setuptools.dist import _get_unpatched
  File "c: \ users \ namar \ appdata \ local \ temp \ tmp1tanvy \ setuptools-2.1 \ setuptools \ di
st.py ", line 15, in 
    from setuptools.compat import numeric_types, basestring
  File "c: \ users \ namar \ appdata \ local \ temp \ tmp1tanvy \ setuptools-2.1 \ setuptools \ co
mpat.py ", line 19, in 
    from SimpleHTTPServer import SimpleHTTPRequestHandler
  File "c: \ python27 \ lib \ SimpleHTTPServer.py", line 27, in 
    class SimpleHTTPRequestHandler (BaseHTTPServer.BaseHTTPRequestHandler):
  File "c: \ python27 \ lib \ SimpleHTTPServer.py", line 208, in SimpleHTTPRequestHand
ler
    mimetypes.init () # try to read system mime.types
  File "c: \ python27 \ lib \ mimetypes.py", line 358, in init
    db.read_windows_registry ()
  File "c: \ python27 \ lib \ mimetypes.py", line 258, in read_windows_registry
    for subkeyname in enum_types (hkcr):
  File "c: \ python27 \ lib \ mimetypes.py", line 249, in enum_types
    ctype = ctype.encode (default_encoding) # omit in 3.x!
UnicodeDecodeError: 'ascii' codec can't decode byte 0xae in position 11: ordinal
 not in range (128)
Something went wrong during the installation.
See the error message above.


C: \ Users \ namar \ Downloads> cd \

C: \> cd Python27
+2
source share
4 answers

I met the same problem, resolving it, removing the non-ASCII character in the Windows registry "HKEY_CLASSES_ROOT \ MIME \ Database \ Content Type" and it works. Cause:

 ctype = ctype.encode(default_encoding)  

will throw a UnicodeDecodeError when it encounters non-ASCII characters and the program stops.

+1
source

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

C:\Python27\Lib\mimetypes.py

default_encoding = sys.getdefaultencoding()

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

: 'gbk' .

+1

C:\Python27\Lib\mimetypes.py

default_encoding = sys.getdefaultencoding()

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

Note: instead of 'gbk' select your encoding.

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

0
source

In my case, just comment on the following four lines:

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

And replace UnicodeEncodeErrorwith UnicodeError.

For more information you can check this question.

0
source

Source: https://habr.com/ru/post/1524409/


All Articles