使用ez_setup.py安装setuptools报错

注意,如是你用的是python-2.7.6.amd64请先卸载,再下载python-2.7.3.amd64或python-2.7.5.amd64安装,使用2.7.6版也会导致如下问题,原因暂时不详。

搭建robotframework自动化框架环境时,使用ez_setup.py安装setuptools报错如下

C:\Python27>python ez_setup.py
Downloading https://pypi.python.org/packages/source/s/setuptools/setuptools-1.4.2.tar.gz
Extracting in c:\users\907379\appdata\local\temp\tmpvmiaeq
Now working in c:\users\907379\appdata\local\temp\tmpvmiaeq\setuptools-1.4.2
Installing Setuptools
Traceback (most recent call last):
  File "setup.py", line 17, in <module>
    exec(init_file.read(), command_ns)
  File "<string>", line 8, in <module>
  File "c:\users\907379\appdata\local\temp\tmpvmiaeq\setuptools-1.4.2\setuptools\__init__.py", line 11, in <module>
    from setuptools.extension import Extension
  File "c:\users\907379\appdata\local\temp\tmpvmiaeq\setuptools-1.4.2\setuptools\extension.py", line 5, in <module>
    from setuptools.dist import _get_unpatched
  File "c:\users\907379\appdata\local\temp\tmpvmiaeq\setuptools-1.4.2\setuptools\dist.py", line 15, in <module>
    from setuptools.compat import numeric_types, basestring
  File "c:\users\907379\appdata\local\temp\tmpvmiaeq\setuptools-1.4.2\setuptools\compat.py", line 19, in <module>
    from SimpleHTTPServer import SimpleHTTPRequestHandler
  File "C:\Python27\lib\SimpleHTTPServer.py", line 27, in <module>
    class SimpleHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
  File "C:\Python27\lib\SimpleHTTPServer.py", line 208, in SimpleHTTPRequestHandler
    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 0x97 in position 0: ordinal not in range(128)
Something went wrong during the installation.
See the error message above.

解决方法如下:

通过分析最后的错误提示,是由于setuptools包中的setup.py编码格式错误,导致无法安装,以上虽然报错,但是setuptools-1.4.2.tar.gz已经下载完成。那么就可以通过手工安装setuptools包:

1、解压setuptools-1.4.2.tar.gz至C:\Python27\Lib\site-packages\setuptools-1.4.2n27\Lib\site-packages\setuptools-1.4.2

2、修改setup.py,在代码中添加如下几句即可: 

import sys
reload(sys)
sys.setdefaultencoding('utf8')也可能是’gbk’

3、在cmd窗口中进入Python27\Lib\site-packages\setuptools-1.4.2目录,然后输入:python setup.py install,即可安装成功



评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值