python安装easy_install失败的解决办法

系统:win7 64位
python:版本2.7.6
报错信息:

Traceback (most recent call last):
File "c:\docume~1\admini~1\locals~1\temp\tmpbg7qjrpycharm-management\setuptools-1.1.5\setup.py", line 17, in 
exec(init_file.read(), command_ns)
File "", line 8, in 
File "c:\docume~1\admini~1\locals~1\temp\tmpbg7qjrpycharm-management\setuptools-1.1.5\setuptools\__init__.py", line 11, in 
from setuptools.extension import Extension
 ......
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 0xd7 in position 9: ordinal not in range(128)

解决办法:

python安装目录Libmimetypes.py中,

default_encoding = sys.getdefaultencoding()

这句之前加上设置默认编码,添加如下语句:

reload(sys)
sys.setdefaultencoding("cp936")

参考链接:文章传送门

------------update------------------
用上述办法后,如果你要使用easy_install安装python的第三方模块,千万不能删除上述语句。
如果删除上述语句后,将会报错如下:

ctype = ctype.encode(default_encoding) # omit in 3.x!
UnicodeDecodeError: 'ascii' codec can't decode byte 0xb0 in position 1: ordinalnot in range(128)

还是编码问题。所以暂时还不能删掉上述语句,如果插入的语句影响到你功能开发,那就先注释掉;要用easy_install安装第三方模块再恢复。(刚刚入门的python菜鸟想到的办法 stQ

你可能感兴趣的:(python安装easy_install失败的解决办法)