pypa/pip · error · UnsupportedPythonVersion
Package requires a different Python: not in
Error message
Package {dist.raw_name!r} requires a different Python: {version} not in {requires_python!r} What it means
_check_metadata_requires_python (resolver.py:105) raises UnsupportedPythonVersion when the running interpreter's version falls outside the package's Requires-Python specifier and --ignore-requires-python is not set. pip checks this to prevent installing a package that declares it cannot run on the current Python.
Solutions
- Switch to a compatible Python version (pyenv use 3.x / create a matching venv).
- Pin the package to an older release that supports your Python version.
- Pass --ignore-requires-python (risky: may install an unusable package).
Example fix
# before pip install newpkg # requires Python >=3.10, you run 3.8 # after pyenv install 3.11 && pyenv shell 3.11 && pip install newpkg
Defensive patterns
Strategy: validation
Validate before calling
# Before installing, check the package's Requires-Python against your interpreter.
import sys, subprocess, json
ver = f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}"
# e.g. using the JSON API
import urllib.request
for pkg in ["numpy"]:
data = json.load(urllib.request.urlopen(f"https://pypi.org/pypi/{pkg}/json"))
rp = data["info"].get("requires_python", "")
print(f"{pkg} requires_python={rp}; you run {ver}") Prevention
- Keep your interpreter on a supported Python version per the project's constraints.
- Pin dependency versions known to support your Python.
- Use pyenv or pyenv-win to switch Python versions per project.
When it happens
Trigger: Installing a package whose Requires-Python (e.g. >=3.10) excludes the active interpreter (e.g. 3.8) via the legacy resolver path.
Common situations: Wrong interpreter or venv active; CI pinned to an old Python; a dependency dropped support for your Python version in a new release.
Related errors
- Could not satisfy constraints for
- [dependency-groups] resolution failed for
- Double requirement given
- Invalid requirement
- None metadata found for distribution
AI-assisted analysis of pypa/pip@f399c37189 (2026-08-08).
Data as JSON: /api/errors/05855e3a8dc42b61.
Report an issue: GitHub.
Appendix: source
Thrown at src/pip/_internal/resolution/legacy/resolver.py:105
logger.warning(
"Package %r has an invalid Requires-Python: %s", dist.raw_name, exc
)
return
if is_compatible:
return
version = ".".join(map(str, version_info))
if ignore_requires_python:
logger.debug(
"Ignoring failed Requires-Python check for package %r: %s not in %r",
dist.raw_name,
version,
requires_python,
)
return
raise UnsupportedPythonVersion(
f"Package {dist.raw_name!r} requires a different Python: "
f"{version} not in {requires_python!r}"
)
class Resolver(BaseResolver):
"""Resolves which packages need to be installed/uninstalled to perform \
the requested operation without breaking the requirements of any package.
"""
_allowed_strategies = {"eager", "only-if-needed", "to-satisfy-only"}
def __init__(
self,
preparer: RequirementPreparer,
finder: PackageFinder,
wheel_cache: WheelCache | None,
make_install_req: InstallRequirementProvider,View on GitHub (pinned to f399c37189)