You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何解决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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.17 17:47:36