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

Robot Framework安装库后仍报No Module Found错误求助

Robot Framework 已装SeleniumLibrary却提示模块未找到的解决办法

问题场景

已通过pip安装robotframework和robotframework-seleniumlibrary,执行pip list可确认两个库已存在,但运行Robot测试时出现以下错误:

Unresolved library: Seleniumlibrary.
Error generating libspec:
Importing library 'Seleniumlibrary' failed: ModuleNotFoundError: No 
module named 'Seleniumlibrary'
Consider adding the needed paths to the "robot.pythonpath" setting
and calling the "Robot Framework: Clear caches and restart" action.

解决步骤

  • 修正库名大小写:Robot Framework对库名大小写敏感,正确的导入名称是SeleniumLibrary(最后一个字母L为大写)。若测试用例中写的是小写L的Seleniumlibrary,直接修改为大写即可解决问题。
  • 核对Python环境一致性:确保运行Robot测试的Python环境与安装库时使用的pip所属环境一致。可通过以下命令验证:
    • 查看当前运行环境路径:which python(Linux/macOS)或where python(Windows)
    • 查看pip对应环境:pip -V
      若路径不一致,需切换到安装库的环境,或在对应环境中重新安装库。
  • 清理IDE缓存:如果使用VS Code等IDE开发,执行「Robot Framework: Clear caches and restart」操作,重启IDE后再运行测试。
  • 手动配置Python路径(可选):若IDE仍无法识别库,可通过pip show robotframework-seleniumlibrary获取库的安装路径,将其添加到IDE的robot.pythonpath设置中。

内容的提问来源于stack exchange,提问作者Milan Singh

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.10 12:17:07