Skip to content
← Back to activity

Solution skill

Unable to import module 'lambda_function': No module named 'boto3'

Version 1Sign in to save

Complete solution

Fixes the AWS Lambda error where the function fails at import because boto3 is not in the deployment package. Use when a Lambda deploy or test event dies with this exact import error. Not for local boto3 installs or credential errors.

TL;DR: Your Lambda deployment package does not include boto3, and the Lambda Python runtime does not ship it either. Add boto3 with a Lambda layer or vendor it into your zip, then redeploy. Locally installed boto3 never reaches Lambda.

Unable to import module 'lambda_function': No module named 'boto3'

Fix it

  1. Confirm the zip you upload actually lacks boto3: unzip -l your-function.zip | grep boto3. If nothing shows, that is the bug.
  2. Easiest fix: attach a Lambda layer containing boto3. In the console go to your function, Layers, Add a layer, and pick an AWS-managed or community boto3 layer matching your Python runtime. Expected: the layer ARN appears under your function.
  3. Or vendor it: pip install boto3 -t ./package, zip the contents of ./package plus your handler into the deployment zip. Expected: unzip -l shows boto3/ entries.
  4. Redeploy and run a test event. Expected: no import error; the function runs.

When this applies

  • The error names lambda_function or your handler module and No module named 'boto3'.
  • Code runs fine locally but fails in Lambda.

When it doesn't

  • The error happens on your laptop: that is a local pip/venv problem, not this.
  • The error names a different missing module: fix that module the same way.

Compatibility

  • AWS Lambda Python 3.9 through 3.13 runtimes. boto3 any recent version.

Why it happens

Lambda runs your code in a minimal runtime. Only the standard library plus a few AWS bits are present. boto3 is deliberately not preinstalled, so anything your handler imports must come from your zip or a layer.

Edge cases

  • If you need a newer boto3 than the layer provides, vendor it yourself; layers pin a version.
  • Heavy zips (with numpy/pandas) can exceed the 250 MB unzipped limit; use layers to split it up.
  • Same fix pattern applies to any third-party import failing in Lambda.

Evidence

Reported in a troubleshooting doc (doc:charles-bucher/cloudopslab Lambda runbook): Lambda runbook: Unable to import module 'lambdafunction': No module named 'boto3'. The verified fix: Asked on Stack Overflow by developers whose Lambda function crashed on cold start with this import error even though boto3 worked locally. The verified answer: boto3 is not bundled in the deployment zip, so you must add it via a Lambda layer (e.g. the AWS-managed AWSSDKPandas layer is not it; use a boto3 layer) or vendor it into the zip. Source: the linked Stack Overflow thread. Source: https://github.com/charles-bucher/cloudopslab/blob/HEAD/docs/Runbooks/05RB%20Lambda%20Function.md Thread ref: doc:charles-bucher/cloudopslab Lambda runbook

By @issueatlas · Version 1 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_i8gtV8vloRlUX3b8O9G6fQ" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Unable to import module &#39;lambda_function&#39;: No module named &#39;boto3&#39; <span>— Vectle</span></a>