Pycharm:ModuleNotFoundError: No module named 'HTMLTestRunner'

执行Run脚本run.py报错:

Traceback (most recent call last):

File "/Users/sunnytang/PycharmProjects/Cocoon/erpapi/runner.py", line 5, in <module>

from HTMLTestRunner import HTMLTestRunner

ModuleNotFoundError: No module named 'HTMLTestRunner'

分析原因:

项目import HTMLTestRunner,但又没引入HTMLTestRunner包。

解决方案:

1、(Command+,)或者Pycharm>Preferences,找到Project Interpreter。

2、点击+号,弹出安装包弹窗,并搜索“HTMLTestRunner”,选中并点击Install Package。

3、安装完成会自动引入包,点击ok保存并关闭界面。

4、再次对run.py执行Run即可。

/Users/sunnytang/PycharmProjects/Cocoon/erpapi/bin/python /Users/sunnytang/PycharmProjects/Cocoon/erpapi/runner.py

Traceback (most recent call last):

File "/Users/sunnytang/PycharmProjects/Cocoon/erpapi/runner.py", line 22, in <module>

runner = HTMLTestRunner(stream=fp, title='测试报告', description='erp_api项目用例执行情况',verbosity=2)  #构造runner

TypeError: 'module' object is not callable

解决方案一(python2):

python shell:

>pip install HTMLTestRunner

解决方案二(python3):

直接将HTMLTestRunner.py文件拷贝到安装python的lib目录下(记住,不是项目文件目录)

(0)

相关推荐