Python3安装robotframework-ExcelLibary
robotFramework-ExcelLibrary这个库是用来操作excel文件的,ExcelLibrary库目前最新的是.0.02版本,只支持Python2,Python3需要离线安装ExcelLibrary库并且还需要进行一些语法的修改。文件下载地址:https://files.pythonhosted.org/packages/b8/e7/8c079a814e7ad288ec2fc15671d8dc526e3d537bb00e4ab2b209a63674ed/robotframework-excellibrary-0.0.2.zip
使用pip install robotframework-excellibrary,会报错:
execfile(join(dirname(file), ‘ExcelLibrary’, ‘version.py’)) NameError: name ‘execfile’ is not defined
这个是因为,在3.x中execfile被废弃了,需要使用exec函数来代替。 同时,3.x print是个函数,必须加小括号进行函数调用, 需要进行的修改包括:
文件 setup.py
#execfile(join(dirname(file), ‘ExcelLibrary’, ‘version.py’))
exec(open(join(dirname(file), ‘ExcelLibrary’, ‘version.py’)).read())
文件 ExcelLibrary.py
将所有的print xxx 语句修改为 print(xxx)
文件 init.py
#from ExcelLibrary import ExcelLibrary
#from version import VERSION
from .ExcelLibrary import ExcelLibrary
from .version import VERSION
文件 ExcelLibrary.py
#from version import VERSION
from .version import VERSION ExcelLibrary.py中导入包xlrd,xlwt,xlutils都需要通过pip去安装,操作很简单,就不演示了。
根据上面所述去进行修改后,使用 python setup.py install, 然后可以使用pip list继续查看。