1、python安装pytest,需要的插件
建议下载最新版本
atomicwrites
attrs
colorama
importlib_metadata
more_itertools
packaging
pluggy
py
pyparsing
six
wcwidth
zipp
pytest
或者:
链接:https://pan.baidu.com/s/109YcYMBRxwAAoHFIXoVAZA
提取码:dmnt
2、下载地址
https://pypi.org/project/pluggy/#files
3、安装
pip install xxxx(插件全名)
4、查看是否安装成功
在控制台输入Python
接着输入 import pytest,如果不给报错,就证明安装成功
5、报错
Traceback (most recent call last): File "D:/java/idea/workSpaces/test/pythonWeb/webmoutrs/com_pytest/test_pytest01.py", line 1, in <module> import pytest File "D:pythonpythonRootlibsite-packagespytest.py", line 8, in <module> from _pytest.assertion import register_assert_rewrite File "D:pythonpythonRootlibsite-packages\_pytestassertion\__init__.py", line 13, in <module> from _pytest.assertion import rewrite File "D:pythonpythonRootlibsite-packages\_pytestassertion ewrite.py", line 24, in <module> from _pytest.assertion import util File "D:pythonpythonRootlibsite-packages\_pytestassertionutil.py", line 11, in <module> import _pytest._code File "D:pythonpythonRootlibsite-packages\_pytest\_code\__init__.py", line 7, in <module> from .code import Code # noqa File "D:pythonpythonRootlibsite-packages\_pytest\_codecode.py", line 15, in <module> import pluggy File "D:pythonpythonRootlibsite-packagespluggy\__init__.py", line 16, in <module> from .manager import PluginManager, PluginValidationError File "D:pythonpythonRootlibsite-packagespluggymanager.py", line 6, in <module> import importlib_metadata File "D:pythonpythonRootlibsite-packagesimportlib_metadata\__init__.py", line 471, in <module> __version__ = version(__name__) File "D:pythonpythonRootlibsite-packagesimportlib_metadata\__init__.py", line 438, in version return distribution(package).version File "D:pythonpythonRootlibsite-packagesimportlib_metadata\__init__.py", line 411, in distribution return Distribution.from_name(package) File "D:pythonpythonRootlibsite-packagesimportlib_metadata\__init__.py", line 179, in from_name dists = resolver(name) File "<frozen importlib._bootstrap_external>", line 1382, in find_distributions File "D:pythonpythonRootlibimportlibmetadata.py", line 400, in find_distributions found = cls._search_paths(context.pattern, context.path) AttributeError: 'str' object has no attribute 'pattern' Process finished with exit code 1
由报错信息显示三个地方的site-packages出错:
D:pythonpythonRootlibsite-packagesimportlib_metadata\__init__.py"
"D:pythonpythonRootlibsite-packagespluggy\_init__.py",
"D:pythonpythonRootlibsite-packages\_pytestassertion\__init__.py"
解决方法:
查看pytest所依赖的这三个包的版本,将其更新至需要版本