pypa/pip · critical · RuntimeError
Python 3.8 or later is required
Error message
Python 3.8 or later is required
What it means
A module-level guard at the top of pkg_resources.__init__ that raises RuntimeError if the running Python interpreter is older than 3.8. Because it executes at import time, importing pkg_resources (or any code that imports it) on Python 3.7 or earlier immediately aborts with this message. pkg_resources is deprecated and has dropped support for old Python versions.
Solutions
- Upgrade the Python interpreter to 3.8 or newer (3.8 itself is EOL — prefer 3.10+).
- Update the base Docker image to one shipping a supported Python version.
- Pin to an older pkg_resources/setuptools/pip release that supports your interpreter only as a temporary bridge, then migrate.
Example fix
// before # Dockerfile FROM python:3.7-slim RUN pip install setuptools // after FROM python:3.11-slim RUN pip install setuptools
Defensive patterns
Strategy: validation
Validate before calling
import sys
if sys.version_info < (3, 8):
raise SystemExit('Python 3.8+ required; current: ' + sys.version)
import pkg_resources Prevention
- Declare python_requires='>=3.8' in your packaging config.
- Pin CI/Docker base images to Python 3.10+.
- Document the minimum Python version prominently.
When it happens
Trigger: Running `import pkg_resources` on CPython 3.7 or older; running a tool that transitively imports pip._vendor.pkg_resources on a legacy interpreter.
Common situations: A CI job or Docker image still pinned to Python 3.7; a system Python on an older OS (e.g. older Debian/Ubuntu) where a script invokes pip/setuptools vendored pkg_resources; upgrading pip/setuptools on an old Python.
Related errors
- python_full_version in provided environment does not…
- invalid sysconfig.get_config_var('EXT_SUFFIX')
- Provided environment does not satisfy any of the…
- python_full_version in provided environment does not…
- python_version must contain at least one item
AI-assisted analysis of pypa/pip@f399c37189 (2026-08-08).
Data as JSON: /api/errors/9dee09ca8339d240.
Report an issue: GitHub.
Appendix: source
Thrown at src/pip/_vendor/pkg_resources/__init__.py:28
to have their path parts separated with ``/``, *not* whatever the local
path separator is. Do not use os.path operations to manipulate resource
names being passed into the API.
The package resource API is designed to work with normal filesystem packages,
.egg files, and unpacked .egg files. It can also work in a limited way with
.zip files and with custom PEP 302 loaders that support the ``get_data()``
method.
This module is deprecated. Users are directed to :mod:`importlib.resources`,
:mod:`importlib.metadata` and :pypi:`packaging` instead.
"""
from __future__ import annotations
import sys
if sys.version_info < (3, 8): # noqa: UP036 # Check for unsupported versions
raise RuntimeError("Python 3.8 or later is required")
import os
import io
import time
import re
import types
from typing import (
Any,
Literal,
Dict,
Iterator,
Mapping,
MutableSequence,
NamedTuple,
NoReturn,
Tuple,
Union,
TYPE_CHECKING,View on GitHub (pinned to f399c37189)