注意,如是你用的是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
exec(init_file.read(), command_ns)
File "", line 8, in
File "c:\users\907379\appdata\local\temp\tmpvmiaeq\setuptools-1.4.2\setuptools\__init__.py", line 11, in
from setuptools.extension import Extension
File "c:\users\907379\appdata\local\temp\tmpvmiaeq\setuptools-1.4.2\setuptools\extension.py", line 5, in
from setuptools.dist import _get_unpatched
File "c:\users\907379\appdata\local\temp\tmpvmiaeq\setuptools-1.4.2\setuptools\dist.py", line 15, in
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
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 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,即可安装成功