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
相关产品推荐
相关产品推荐

