编解码器无法解码位置

编解码器无法解码位置

本文介绍了Python ez_install:UnicodeDecodeError:“ascii"编解码器无法解码位置 11 中的字节 0xae的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试使用全新 Python 2.7 安装 ez_install、Windows 7 64 位机器时出现以下错误.有什么想法吗?

安装安装工具回溯(最近一次调用最后一次):文件setup.py",第 17 行,在执行(init_file.read(),command_ns)文件",第 8 行,在文件c:\users\namar\appdata\local\temp\tmp1tanvy\setuptools-2.1\setuptools\__init__.py",第 11 行,在从 setuptools.extension 导入扩展文件c:\users\namar\appdata\local\temp\tmp1tanvy\setuptools-2.1\setuptools\ex张力.py",第 5 行,在从 setuptools.dist 导入 _get_unpatched文件c:\users\namar\appdata\local\temp\tmp1tanvy\setuptools-2.1\setuptools\dist.py",第 15 行,在从 setuptools.compat 导入 numeric_types, basestring文件c:\users\namar\appdata\local\temp\tmp1tanvy\setuptools-2.1\setuptools\compat.py",第 19 行,在从 SimpleHTTPServer 导入 SimpleHTTPRequestHandler文件c:\python27\lib\SimpleHTTPServer.py",第 27 行,在类 SimpleHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):文件c:\python27\lib\SimpleHTTPServer.py",第 208 行,在 SimpleHTTPRequestHand 中勒mimetypes.init() # 尝试读取系统 mime.types文件c:\python27\lib\mimetypes.py",第 358 行,在 init 中db.read_windows_registry()文件c:\python27\lib\mimetypes.py",第 258 行,在 read_windows_registry对于 enum_types(hkcr) 中的子键名:文件c:\python27\lib\mimetypes.py",第 249 行,在 enum_types 中ctype = ctype.encode(default_encoding) # 3.x 中省略!UnicodeDecodeError: 'ascii' 编解码器无法解码位置 11 中的字节 0xae:序数不在范围内(128)安装过程中出现问题.请参阅上面的错误消息.C:\用户\namar\下载>cd\C:\>cd Python27
解决方案

检查此链接.(http://blog.csdn.net/hugleecool/article/details/17996993).

在 C:\Python27\Lib\mimetypes.py 中找到下一个字符串

default_encoding = sys.getdefaultencoding()

替换为

if sys.getdefaultencoding() != 'gbk':重新加载(系统)sys.setdefaultencoding('gbk')default_encoding = sys.getdefaultencoding()

注意:改为gbk"选择您的编码.

Getting the error below trying to install ez_install, Windows 7 64 bit 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
解决方案

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.

这篇关于Python ez_install:UnicodeDecodeError:“ascii"编解码器无法解码位置 11 中的字节 0xae的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 04:48