如何解决Robot Framework中DataDriver的ImportError:无法从pandas.compat导入FileNotFoundError
解决DataDriver库导入报错问题
报错详情
鼠标悬停DataDriver库时触发如下错误:
Unresolved library: DataDriver. Error generating libspec: Importing library 'DataDriver' failed: ImportError: cannot import name : "FileNotFoundError" from 'pandas.compat' (C:\Users\myuser\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pandas\compat\__init__.py) Consider adding the needed paths to the "robot.pythonpath" setting and calling the "Robot Framework: Clear caches and restart" action.robotframework
代码截图

解决方法
- 适配pandas版本:Python3.7不兼容pandas 2.x及以上版本,这类版本已移除
pandas.compat模块中的FileNotFoundError导出,安装兼容的1.x版本:pip install pandas==1.3.5 - 确认DataDriver安装状态:确保robotframework-datadriver已正确安装:
pip install robotframework-datadriver - 清理缓存并重启:在VS Code中执行
Robot Framework: Clear caches and restart操作,刷新库解析缓存。 - 配置Python路径:在VS Code的settings.json中添加Python site-packages路径到
robot.pythonpath:"robot.pythonpath": ["C:\\Users\\myuser\\AppData\\Local\\Programs\\Python\\Python37-32\\lib\\site-packages"]
内容的提问来源于stack exchange,提问作者Rica Jacutina
相关产品推荐
相关产品推荐

