问题描述:
在使用py2exe成功生成exe程序后, 运行程序提示如下错误,在本地可以查找到getAttribute.js文件,不明白为何会上报错误。Python版本:2.27
错误信息:
Traceback(most recent call last):
File "explorer.py", line 7, in <module>
File "selenium\webdriver\__init__.pyc", line 18, in <module>
File "selenium\webdriver\firefox\webdriver.pyc", line 26, in <module>
File "selenium\webdrvier\remote\webelement.pyc", line 43, in <module>
File "pkgutil.pyc", line 591, in get_data
IOError:[Errno 2] No such file or directory:'selenium\\webdriver\\remote\\getAttribute.js'
经过广泛的资料查找,终于找到一种解决方法。
py2exe生成的exe运行时依赖library.zip,报错的原因就是因为在压缩文件中的selenium\webdriver\remote\中未找到getAttribute.js文件。
找到问题原因后,通过手动添加缺少的文件到压缩包对应的路径下,重新运行程序后验证,问题解决。