Runtime.ImportModuleError AWS Origin: Platform & cloud Last updated 14 Oct 2026

Runtime.ImportModuleError: Unable to import module 'lambda_function': No module named 'x'

Lambda couldn’t load your handler file or one of its dependencies — the package is missing from the deployment zip/layer or the handler path is wrong.

Exact message you may see Unable to import moduleNo module namedCannot find moduleError: Cannot find package
Seen on: AWS

Meaning

Lambda only has what you upload plus the runtime. pip/npm dependencies must be inside the zip (or a layer) at the right path, compiled for Amazon Linux and the function’s architecture. Node ESM/CommonJS mismatches produce the same error type.

Common causes

  • Dependencies not included in the zip/layer
  • Handler file not at the zip root (nested folder)
  • Native packages built on macOS/Windows or for the wrong architecture (arm64 vs x86_64)
  • Node: ESM import in a CommonJS handler (or vice versa)

⚡ Quick fix

  1. Install dependencies into the package directory and zip from inside it
  2. Check the handler setting matches file.function
  3. Build native deps for Amazon Linux (Docker/sam build --use-container)

Detailed fix by platform

Python

  1. python
    pip install -r requirements.txt -t package/
    cp lambda_function.py package/
    cd package && zip -r ../function.zip .

AWS CLI

  1. sam build --use-container && sam deploy

How to diagnose

  1. Zip — unzip -l function.zip | head (file at root?)
  2. Handler — Configuration → Runtime settings
  3. Arch — Function architecture vs wheels

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Platform & cloud. Errors that are often confused with or caused by this one (click to open):

0x8007007E — 0x8007007E: The specified module could not be found (Windows)0x8007007EClassNotFoundException — java.lang.ClassNotFoundException / NoClassDefFoundError (Java)ClassNotFoundExceptionCocoaPods compatible versions — CocoaPods could not find compatible versions for pod (iOS)CocoaPods compatible …Composer conflict — Your requirements could not be resolved to an installable set of packages. (PHP)Composer conflictCould not resolve — Gradle: Could not resolve all files for configuration / Could not resolve dependency (Android)Could not resolveDEP0040 — DeprecationWarning: The `punycode` module is deprecated (DEP0040) (Node.js)DEP0040Dependency requires compileSdk — Dependency 'androidx.x:1.y' requires libraries and applications that depend on it to compile against version 34 or later of the Android APIs (Android)Dependency requires c…Duplicate class — Duplicate class X found in modules A and B (Android)Duplicate classRuntime.I…

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.