aio-libs/aiohttp · critical · RuntimeError
aiohttp 4.x requires Python 3.10+
Error message
aiohttp 4.x requires Python 3.10+
What it means
Raised by setup.py at install time when the running interpreter is older than Python 3.10. aiohttp 4.x dropped support for Python < 3.10, so the build gates on sys.version_info and aborts before any extension compilation or packaging. This is a hard version floor, not a soft warning.
Source
Thrown at setup.py:9
import os
import pathlib
import sys
from setuptools import Extension, setup
from setuptools.command.build_ext import build_ext
if sys.version_info < (3, 10):
raise RuntimeError("aiohttp 4.x requires Python 3.10+")
USE_SYSTEM_DEPS = bool(
os.environ.get("AIOHTTP_USE_SYSTEM_DEPS", os.environ.get("USE_SYSTEM_DEPS"))
)
NO_EXTENSIONS: bool = bool(os.environ.get("AIOHTTP_NO_EXTENSIONS"))
CYTHON_TRACING: bool = bool(os.environ.get("AIOHTTP_CYTHON_TRACE"))
HERE = pathlib.Path(__file__).parent
IS_GIT_REPO = (HERE / ".git").exists()
if sys.implementation.name != "cpython":
NO_EXTENSIONS = True
if (
not USE_SYSTEM_DEPS
and IS_GIT_REPOView on GitHub (pinned to c0ef574e29)
Solutions
- Upgrade the interpreter to Python 3.10 or newer and reinstall aiohttp in a fresh venv.
- Pin aiohttp to the 3.x line (`aiohttp<4`) if you must stay on Python 3.9.
- Update CI/Docker base images to a 3.10+ Python before installing.
Example fix
# before: python 3.9 pip install aiohttp # -> RuntimeError: aiohttp 4.x requires Python 3.10+ # after: use python 3.10+ python3.10 -m venv .venv && . .venv/bin/activate pip install aiohttp
Defensive patterns
Strategy: validation
Validate before calling
import sys
def assert_python_310():
if sys.version_info < (3, 10):
raise RuntimeError("aiohttp 4.x requires Python 3.10+") Type guard
import sys
def supports_aiohttp4() -> bool:
return sys.version_info >= (3, 10) Prevention
- Install aiohttp 4.x only on Python 3.10+.
- Pin `aiohttp<4` in requirements if you must stay on 3.9.
- Bump base images/CI Python to 3.10+ before upgrading aiohttp.
When it happens
Trigger: Running `pip install aiohttp` (from sdist) or `pip install -e .` in this repo on Python 3.9 or earlier. The check at setup.py:8-9 raises RuntimeError immediately.
Common situations: A project or CI image still pinned to Python 3.9 attempting to install aiohttp 4.x; upgrading aiohttp without upgrading the runtime; a base image whose default python is 3.9; an old virtualenv used to build aiohttp.
Related errors
- OPTIONS route was set already
- SSL is not supported.
- Use Python 3.11+ to run 'make sync-direct-runtime-deps'
AI-assisted analysis of aio-libs/aiohttp@c0ef574e29 (2026-08-04).
Data as JSON: /data/errors/44aa01424d2cf8aa.json.
Report an issue: GitHub.