jenkins+pytest+allure+python ModuleNotFoundError: No module named 'pytest'

 

Traceback (most recent call last):
  File "main.py", line 1, in <module>
    import pytest
ModuleNotFoundError: No module named 'pytest'
当程序在本地可以运行并可生成报告,但是在jenkins里面提示找不到pytest库之类的,这种情况多半是pycharm工具第三方插件安装在默认的路径中,没有跟python环境的路径一致。所以jenkins找不到,本地pycharm可以找到。需要手动去pytest库(删除整个路径),删除后,在cmd中使用命令安装,安装的同时可以看到路径跟python的安装路径是一致的。
手动安装命令:
pip install pytest-html  自动生成 HTML 格式测试报告
pip install pytest-describe  给测试用例一个美丽的名字
pip install pytest-autochecklog(不只是自动生成测试日志)
pip install sugar  测试进度可视化
pip install ordering  改变测试用例的顺序
pip install allure-pytest (生成 allure报告)


posted @ 2022-05-06 11:15  GoodMorning9527  阅读(766)  评论(0编辑  收藏  举报