aio-libs/aiohttp · error · RuntimeError
Use Python 3.11+ to run 'make sync-direct-runtime-deps'
Error message
Use Python 3.11+ to run 'make sync-direct-runtime-deps'
What it means
Raised by requirements/sync-direct-runtime-deps.py when run on Python < 3.11. The script reads pyproject.toml using the stdlib `tomllib` module, which was only added in Python 3.11; on older interpreters there is no tomllib available so the script refuses to run rather than producing partial or wrong output. It is a maintainer-side build script invoked via `make sync-direct-runtime-deps`.
Solutions
- Run the target under Python 3.11+: `python3.11 $(which make) sync-direct-runtime-deps` or activate a 3.11+ venv first.
- Install tomli and patch the import only if you cannot upgrade (not recommended for a maintainer script — prefer upgrading).
- Confirm the interpreter with `python --version` before invoking make.
Example fix
// before $ python --version Python 3.10.13 $ make sync-direct-runtime-deps RuntimeError: Use Python 3.11+ ... // after $ python3.12 -m venv .venv && source .venv/bin/activate $ make sync-direct-runtime-deps # ok
Defensive patterns
Strategy: validation
Validate before calling
import sys assert sys.version_info >= (3, 11), 'sync-direct-runtime-deps requires Python 3.11+ (for tomllib)'
Type guard
def supports_tomllib() -> bool:
import sys
return sys.version_info >= (3, 11) Try / catch
# raised at script start; switch interpreter rather than catching.
# Guard invocation:
import subprocess, sys
if sys.version_info < (3, 11):
subprocess.check_call(['python3.11', 'requirements/sync-direct-runtime-deps.py'])
else:
... Prevention
- Run maintainer make targets under the project's minimum supported Python (3.11+ here).
- Pin the interpreter in the contributing docs and the dev venv.
- Verify `python --version` before invoking the Makefile.
When it happens
Trigger: Running `make sync-direct-runtime-deps` (or `python requirements/sync-direct-runtime-deps.py`) with a Python 3.10 or older interpreter active in the venv that drives the build.
Common situations: A contributor's pyenv/venv still on 3.10; CI matrix that builds docs/deps with an older Python; running the Makefile target by accident with the system python3 on an older distro.
Related errors
- aiohttp 4.x requires Python 3.10+
- Cannot initialize a TLS-in-TLS connection to host
- Resolver requires aiodns library
AI-assisted analysis of aio-libs/aiohttp@d041d4d0fd (2026-08-11).
Data as JSON: /api/errors/1cd2c7c3ba6089cf.
Report an issue: GitHub.
Appendix: source
Thrown at requirements/sync-direct-runtime-deps.py:10
#!/usr/bin/env python
"""Sync direct runtime dependencies from pyproject.toml to runtime-deps.in."""
import sys
from pathlib import Path
if sys.version_info >= (3, 11):
import tomllib
else:
raise RuntimeError("Use Python 3.11+ to run 'make sync-direct-runtime-deps'")
data = tomllib.loads(Path("pyproject.toml").read_text())
reqs = (
data["project"]["dependencies"]
+ data["project"]["optional-dependencies"]["speedups"]
)
reqs = sorted(reqs, key=str.casefold)
with open(Path("requirements", "runtime-deps.in"), "w") as outfile:
header = "# Extracted from `pyproject.toml` via `make sync-direct-runtime-deps`\n\n"
outfile.write(header)
outfile.write("\n".join(reqs) + "\n")
View on GitHub (pinned to d041d4d0fd)