What this thread does
Do first: run sam build --use-container after matching the function's Runtime and Architectures to its native Python dependencies.
Short answer
As of November 2026, AWS SAM CLI 1.174.0 is the release reference. Use the container path for compiled extensions when the host Python/OS/CPU differs from Lambda. The container option builds the function inside a Lambda-like Docker container; dependency failures still require checking the failing dependency, wheel tags and build prerequisites (build reference, Python packaging).
Choose / don't choose
- Native dependencies: choose container builds for Lambda-compatible compilation; don't package macOS or Windows binaries into a Linux deployment.
- Pure Python or matching Linux build environment: a host build can be appropriate; don't infer ABI compatibility just from an identical package name.
- Custom build image: choose only when the default runtime image lacks required system libraries/tools; keep its Python minor version and CPU target aligned (image catalog, Python packaging).
Not for: choosing a serverless deployment framework; see aws-serverless-setup-sst-serverless-or-sam.
Settings that matter
| Setting or flag | Value / default | Applies to | Source |
|---|---|---|---|
--use-container | Enable a Lambda-like build container for compiled dependencies | Current SAM CLI build docs | build reference |
Architectures | [x86_64] or [arm64]; default x86_64; select the deployment CPU | Current SAM function template | resource reference |
Runtime | Identifier of the function's runtime; required for Zip functions | Current SAM template and image catalog | resource, catalog |
--build-image | Runtime-specific image URI, optionally Function1=<URI>; requires --use-container; pick matching CPU variant | Current SAM CLI; images for both CPUs available since 1.33.0 | build reference, image catalog |
--no-cached | Rebuild artifacts when investigating dependency changes; cached mode is off by default | Current SAM CLI build docs | build reference |
Order of operations
1. Record the target runtime and CPU. Select its image repository, e.g. public.ecr.aws/sam/build-python3.12; an untagged URI selects the latest image, while a version tag chooses the included SAM CLI release. Don't substitute an arbitrary architecture tag not listed by the image publisher (catalog). 2. Build from the dependency manifest. On failure, identify which pinned dependency lacks a Linux wheel for that Python ABI and CPU; otherwise inspect the source build for missing compiler or system headers. Build source dependencies in compatible Amazon Linux rather than copying host extensions (Python packaging). 3. Rebuild after correcting the dependency/image, then exercise imports in the target runtime before deployment. The container build does not establish application compatibility.
Known failures and fixes
| Error (short quote) | Cause | Fix | Source |
|---|---|---|---|
PythonPipBuilder:ResolveDependencies | Dependency resolution failed; inspect the named package | Read the named failing package and build output; check available compatible wheels, then source-build tooling. Historical wheel-tool advice is not a universal fix | fniko, March 3, 2020, Python packaging |
| Build-image option rejected | --use-container must be specified; otherwise an error results | Add --use-container; select the correct runtime image instead of assuming the host build uses it | build reference |
Sriram-mv recommended container builds in the March 20, 2020 discussion; dperconti reported that the container could still fail. Do not copy old package downgrades from that discussion into a current dependency set.
Missing
- The failing package, wheel inventory, native libraries and deployed runtime are unspecified; no universal dependency upgrade or fixed SAM release follows from the error.
Checked
2026-11-24; SAM CLI 1.174.0 release, current build/template/image references, Lambda Python packaging and the dated fniko/Sriram-mv/dperconti discussion read. No builds or Lambda invocations executed.
Started from a post by @Amazon Web Services, packaged by the editor. Original post