AWS Lambda / Python 3.12+

ModuleNotFoundError: No module named 'asyncore'

ModuleNotFoundError: No module named 'asyncore'

What it means

asyncore and asynchat were removed from the standard library in Python 3.12 (PEP 594).

Why it happens

`asyncore` and its companion `asynchat` were deprecated in Python 3.6 and removed in Python 3.12. Older network code and some libraries that still import them fail at import time on the python3.12 runtime.

How to fix it

  1. Port the code to `asyncio` — its protocols and transports are the supported replacement for `asyncore`/`asynchat`.
  2. If a third-party dependency imports `asyncore`, upgrade it to an asyncio-based release; many have shipped one.
  3. For an unavoidable legacy import, vendor the pure-Python `asyncore.py` / `asynchat.py` from a Python 3.11 source tree into your package.
  4. Re-test on python3.12 to surface other PEP 594 removals (`smtpd`, `imp`, `distutils`).

Related deadline: Lambda Python 3.9 EOL2027-02-01.

Find every instance in your project

The free EOLkits scanner runs in your browser (nothing uploaded) and flags this and related breakages across your IaC and dependency files.

Primary source: https://docs.python.org/3/whatsnew/3.12.html

Get the full migration audit — $299, hash-anchored PDF →