pytest-dev/pytest · error · UsageError
Missing required plugins: {}
Error message
Missing required plugins: {} What it means
The required_plugins ini option lists plugins that must be installed (with optional version specifiers) for the test suite to run. During _validate_plugins(), pytest parses each requirement with packaging.Requirement and checks it against installed plugin distributions. If any are missing or fail the version constraint, pytest raises UsageError listing all missing plugins.
Source
Thrown at src/_pytest/config/__init__.py:1555
plugin_dist_info = {dist.project_name: dist.version for _, dist in plugin_info}
missing_plugins = []
for required_plugin in required_plugins:
try:
req = Requirement(required_plugin)
except InvalidRequirement:
missing_plugins.append(required_plugin)
continue
if req.name not in plugin_dist_info:
missing_plugins.append(required_plugin)
elif not req.specifier.contains(
Version(plugin_dist_info[req.name]), prereleases=True
):
missing_plugins.append(required_plugin)
if missing_plugins:
raise UsageError(
"Missing required plugins: {}".format(", ".join(missing_plugins)),
)
def _warn_or_fail_if_strict(self, message: str) -> None:
strict_config = self.getini("strict_config")
if strict_config is None:
strict_config = self.getini("strict")
if strict_config:
raise UsageError(message)
self.issue_config_time_warning(PytestConfigWarning(message), stacklevel=3)
def _get_unknown_ini_keys(self) -> set[str]:
known_keys = self._parser._inidict.keys() | self._parser._ini_aliases.keys()
return self._inicfg.keys() - known_keys
def parse(self, args: list[str], addopts: bool = True) -> None:
# Parse given cmdline arguments into this config object.View on GitHub (pinned to 98b357f69e)
Solutions
- Install the missing plugins: pip install <plugin_name><specifier>.
- Update the specifier in required_plugins to match the installed version.
- Verify installed plugin versions with pip list | grep pytest-<name>.
- If the requirement string is malformed, correct it to PEP 508 format.
Example fix
# before (pytest.ini) [pytest] required_plugins = pytest-xdist>=4.0 # but pytest-xdist 3.x installed # after (pytest.ini) [pytest] required_plugins = pytest-xdist>=3.0
Defensive patterns
Strategy: validation
Validate before calling
from packaging.requirements import Requirement, InvalidRequirement
from importlib.metadata import distributions
def validate_required_plugins(required: list[str]) -> None:
installed = {dist.metadata['Name'].lower(): dist.version for dist in distributions()}
missing = []
for req_str in required:
try:
req = Requirement(req_str)
except InvalidRequirement:
missing.append(req_str)
continue
name = req.name.lower()
if name not in installed or not req.specifier.contains(installed[name], prereleases=True):
missing.append(req_str)
if missing:
raise EnvironmentError(f'Missing required plugins: {", ".join(missing)}') Prevention
- Install all required_plugins in CI before running pytest: pip install -r requirements-test.txt.
- Keep required_plugins specifiers loose enough to allow patch updates unless a specific feature is needed.
- Run pip list and verify versions match specifiers during environment setup.
When it happens
Trigger: Setting required_plugins in pyproject.toml/pytest.ini (e.g., required_plugins = pytest-xdist>=3.0) when the plugin is not installed or the installed version doesn't satisfy the specifier. The requirement name is not found in plugin_dist_info or fails req.specifier.contains().
Common situations: Fresh clone without installing dev dependencies, CI matrix running an older plugin version, or a version specifier tightened beyond what's installed. Also, a typo in the requirement string causing InvalidRequirement.
Related errors
- plugin {name} cannot be disabled
- Blocking conftest files using -p is not supported: -p no:{na
- Plugins may be specified as a sequence or a ','-separated st
- Error importing plugin "{modname}": {e.args[0]}
- {cat} is not a Warning subclass
AI-assisted analysis of pytest-dev/pytest@98b357f69e (2026-08-04).
Data as JSON: /data/errors/1b0e0992a02c901b.json.
Report an issue: GitHub.