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. If the dependency has no maintained release, replace it; copying removed standard-library modules forward creates an unsupported fork and should not be presented as a durable fix.
  4. Re-test on python3.12 to surface other PEP 594 removals (`smtpd`, `imp`, `distutils`).

Related deadline: Lambda Python 3.9 create/update restrictions2027-02-01.

Check configured patterns in your project

The free EOLkits scanner processes files in your browser and flags selected related patterns in supported IaC and dependency files. File names and contents are not uploaded; bounded aggregate file and finding counts may be sent. It is not a complete source or AWS-account scan.

Prefer a 10-second check? Paste your config into the free AWS EOL checker. Pasted input is not uploaded; bounded first-party usage events may be sent.

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

Inspect the $299 report sample and availability →