阿里旺旺导致的python运行错误

今天用pip时发现好多包无法安装,错误信息为:

File “D:Python2.7.6libmimetypes.py”, line 249, in enum_types
ctype = ctype.encode(default_encoding) # omit in 3.x!
UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0xb0 in position 1: ordinal not in range(128)

之前明明用的好好的,没有问题,怎么突然间就报错了呢,于是到mimetypes.py看看源码到底怎么写的。

打开该文件报错的第249行附近:

try:
    ctype = _winreg.EnumKey(mimedb, i)
except EnvironmentError:
    break
try:
    ctype = ctype.encode(default_encoding) # omit in 3.x!
except UnicodeEncodeError:
    pass

可以看到编码错误的ctype来源于_winreg.EnumKey(),枚举mimedb,mimedb是这段代码所在函数的参数,于是继续找这个函数被调用的地方:

with _winreg.OpenKey(_winreg.HKEY_CLASSES_ROOT, '') as hkcr:
    for subkeyname in enum_types(hkcr):

这是在枚举注册表的HKEY_CLASSES_ROOT,理论上来说,注册表的这里是不会出现中文的,手动打开注册表看个究竟:

图1

呵。。呵。。阿里旺旺,我看你就很可疑!

把这个该死的项删掉,问题解决。

您可能还喜欢...

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注

扫码去手机上看