PyCharm ModuleNotFoundError: No module named ‘pytest‘

问题:

PyCharm中import pytest,运行提示:ModuleNotFoundError: No module named 'pytest'

在Terminal中输入pytest能正常运行用例

原因:

Pycharm里用的解释器可能有多个,当前使用的可能没有按照pytest模块

解决方法:

进入 File->Setting->项目名称->Python Interpreter,解释器列表没有pytest

在终端输入 pip install pytest 进行安装,安装成功,列表中显示pytest,能正常run

PyCharm ModuleNotFoundError: No module named ‘pytest‘_第1张图片

你可能感兴趣的:(pytest,pycharm,pytest,python)