以下错误尝试使用全新的Python 2.7安装ez_install,Windows 7 64位计算机。有什么想法吗?
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
答案 0 :(得分:1)
我遇到了同样的问题,通过删除窗口注册表“HKEY_CLASSES_ROOT \ MIME \ Database \ Content Type”中的非ASCII字符来解决它并且它有效。原因是
ctype = ctype.encode(default_encoding)
在遇到非ASCII字符时会抛出UnicodeDecodeError,程序将停止。
答案 1 :(得分:1)
检查此链接。(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'选择你的编码。
答案 2 :(得分:0)
在C:\Python27\Lib\mimetypes.py
中找到下一个字符串
default_encoding = sys.getdefaultencoding()
替换为
if sys.getdefaultencoding() != 'gbk':
reload(sys)
sys.setdefaultencoding('gbk')
default_encoding = sys.getdefaultencoding()
注意:而不是' gbk'选择你的编码。
上述答案满足我使用谷歌应用引擎本地网络服务器为php和python进行unicode解码错误的情况。
答案 3 :(得分:0)
就我而言,只需评论以下四行,
try:
ctype = ctype.encode(default_encoding) # omit in 3.x!
except UnicodeEncodeError:
pass
将UnicodeEncodeError
替换为UnicodeError
工作。
有关详情,请查看this问题。