pycharm执行pytest报错module ‘pytest’ has no attribute ‘hookimpl’,但是后台执行可以,怎么解决?
python版本
Python 3.9.5 (v3.9.5:0a7dcbdb13, May 3 2021, 13:05:53)
[Clang 12.0.5 (clang-1205.0.22.9)] on darwin
Type “help”, “copyright”, “credits” or “license” for more information.
报错信息
/usr/local/bin/python3.9 /Applications/PyCharm.app/Contents/helpers/pycharm/_jb_pytest_runner.py --path /Users/liuyifei/PycharmProjects/TestByPython/python_base/test_C_0707_ptest.py
Traceback (most recent call last):
File “/Applications/PyCharm.app/Contents/helpers/pycharm/_jb_pytest_runner.py”, line 27, in
if not get_plugin_manager().hasplugin(“pytest-teamcity”):
File “/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/_pytest/config/init.py”, line 294, in get_plugin_manager
return get_config().pluginmanager
File “/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/_pytest/config/init.py”, line 281, in get_config
pluginmanager.import_plugin(spec)
File “/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/_pytest/config/init.py”, line 703, in import_plugin
import(importspec)
File “/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/_pytest/helpconfig.py”, line 97, in
@pytest.hookimpl(hookwrapper=True)
AttributeError: module ‘pytest’ has no attribute ‘hookimpl’