当前位置: 首页 > 工具软件 > ExcelLibrary > 使用案例 >

使用python3.7时,如果为robotframework安装 robotframework-excellibrary

申屠昆
2023-12-01

robotframework-excellibrary这个库是用来操作excel文件的,在python2.7中work的很好,但是在python3.x中,由于python自身的变化,会导致无法安装。

使用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

我们无法通过pip安装,只能手动安装了,下载压缩包解压,根据上面所述去进行修改,使用 python setup.py install, 然后可以使用pip list继续查看。
————————————————

 类似资料: