Hello. You can add a layer to the Lambda function by executing the following command in CloudShell. ``` mkdir python pip3 install bcrypt -t ./python zip -r ./python.zip . aws lambda publish-layer-version --layer-name python-layer --zip-file fileb://python.zip --compatible-runtimes python3.13 aws lambda update-function-configuration --function-name "Your Lambda Function Name" --layers arn:aws:lambda:::layer:python-layer:1 ``` CloudShell can be used by following the steps in the following document: https://docs.aws.amazon.com/cloudshell/latest/userguide/getting-started.html#launch-region-shell Answer from Riku_Kobayashi on repost.aws
🌐
Amazon Web Services
docs.aws.amazon.com β€Ί aws lambda β€Ί developer guide β€Ί building lambda functions with python β€Ί working with layers for python lambda functions
Working with layers for Python Lambda functions - AWS Lambda
This means creating a .zip file archive that contains the dependencies you want to use in your functions. Create the layer in Lambda. Add the layer to your functions. ... To create a layer, bundle your packages into a .zip file archive that meets the following requirements: Build the layer using the same Python version that you plan to use for the Lambda function.
🌐
Amazon Web Services
docs.aws.amazon.com β€Ί aws lambda β€Ί developer guide β€Ί managing lambda dependencies with layers β€Ί packaging your layer content
Packaging your layer content - AWS Lambda
To ensure that Lambda picks up your layer content, your layer .zip file should have its dependencies in one of the following folder paths: The following examples show how you can structure the folders in your layer .zip archive. ... python/ # Required top-level directory └── requests/ └── boto3/ └── numpy/ └── (dependencies of the other packages)
Discussions

Why am I unable to install any dependencies to Lambda Via Layers?
For information on AWS Service migration, see How do I migrate my services to another region? ... I have a simple package I would like to use in my python lambda function: bcrypt. I have tried many ways of installing this dependency, mainly following YT tutorials, but the way that makes the most sense to me is by utilizing layers... More on repost.aws
🌐 repost.aws
2
0
March 26, 2025
amazon web services - How do I add python libraries to an AWS lambda function for Alexa? - Stack Overflow
And it's very important to have the the python package version which matches with the linux version. You may find more information on this on : https://aws.amazon.com/lambda/faqs/ Follow the steps to download the version. 1. Find the .whl image of the package from pypi and download it on you local. 2. Zip the packages and add them as layers ... More on stackoverflow.com
🌐 stackoverflow.com
AWS Lambda python dependencies packaging issues
This documentation might be helpful. https://docs.aws.amazon.com/lambda/latest/dg/python-image.html Also, if you haven’t tried posting in one of the AWS subreddits, you might post there as well. r/AWS More on reddit.com
🌐 r/awslambda
2
2
April 14, 2024
How to run lambda functions with large sized python dependencies?
A Lambda container image has a 10 GB size limit: https://aws.amazon.com/blogs/aws/new-for-aws-lambda-container-image-support/ Use AWS SAM and the SAM CLI with a cloud9 instance and you got everything set up ready to explore how to use it. More on reddit.com
🌐 r/aws
15
10
October 25, 2022
🌐
Amazon Web Services
docs.aws.amazon.com β€Ί aws lambda β€Ί developer guide β€Ί building lambda functions with python β€Ί working with .zip file archives for python lambda functions
Working with .zip file archives for Python Lambda functions - AWS Lambda
Runtime dependencies in PythonCreating a .zip deployment package with no dependenciesCreating a .zip deployment package with dependenciesDependency search path and runtime-included librariesUsing __pycache__ foldersCreating .zip deployment packages with native librariesCreating and updating Python Lambda functions using .zip files Β· Your AWS Lambda function’s code comprises a .py file containing your function’s handler code, together with any additional packages and modules your code depends on.
🌐
Ian Wootten
ianwootten.co.uk β€Ί 2022 β€Ί 01 β€Ί 27 β€Ί how-to-create-aws-lambda-layers-for-python-dependencies
How to Create AWS Lambda Layers for Python Dependencies β€” Ian Wootten
It uses a docker image from lambci and the AWS CLI to build and publish a Lambda Layer to AWS. I’ve modified this below, and created a gist which will install from a requirements.txt file within in the same folder. REGION=eu-west-2 RUNTIME=python3.8 LAYER_NAME=app docker run -v $(pwd):/out -it lambci/lambda:build-$RUNTIME \ pip install -r /out/requirements.txt -t /out/build/$LAYER_NAME/python cd build/$LAYER_NAME zip -r ../../$LAYER_NAME.zip python/ cd ../.. aws lambda publish-layer-version \ --layer-name $LAYER_NAME \ --region $REGION \ --zip-file fileb://$LAYER_NAME.zip \ --compatible-runtimes $RUNTIME rm -rf build *.zip
🌐
Medium
medium.com β€Ί analytics-vidhya β€Ί aws-adding-python-libraries-to-lambda-layers-8c4eaf8fed80
AWS: Adding Python Libraries to Lambda Layers
May 12, 2021 - AWS Lambda Layers: Just package the dependencies into a ZIP file and upload it to AWS. Also, once a layer is defined, all its underlying dependencies can be used by any number of Lambda functions.
🌐
Amazon Web Services
docs.aws.amazon.com β€Ί aws lambda β€Ί developer guide β€Ί managing lambda dependencies with layers
Managing Lambda dependencies with layers - AWS Lambda
Without layers, you need to include the same dependencies in each individual deployment package. To use the Lambda console code editor. The code editor is a useful tool for testing minor function code updates quickly. However, you can’t use the editor if your deployment package size is too large. Using layers reduces your package size and can unlock usage of the code editor. To lock an embedded SDK version.The embedded SDKs may change without notice as AWS ...
🌐
GeeksforGeeks
geeksforgeeks.org β€Ί installation guide β€Ί how-to-install-python-packages-for-aws-lambda-layers
How to Install Python Packages for AWS Lambda Layers? - GeeksforGeeks
July 23, 2025 - If there is a need to update your common code or any dependency you can do so in one place rather than making changes in individual lambda functions. Since lambda layers provide a feature to store different versions you can use the older version of a package or a new version as per the requirements. Note: A lambda function can have up to 5 layers. In this tutorial, we will see how to install python packages for AWS ...
Find elsewhere
Top answer
1 of 2
1
Hello. You can add a layer to the Lambda function by executing the following command in CloudShell. ``` mkdir python pip3 install bcrypt -t ./python zip -r ./python.zip . aws lambda publish-layer-version --layer-name python-layer --zip-file fileb://python.zip --compatible-runtimes python3.13 aws lambda update-function-configuration --function-name "Your Lambda Function Name" --layers arn:aws:lambda:::layer:python-layer:1 ``` CloudShell can be used by following the steps in the following document: https://docs.aws.amazon.com/cloudshell/latest/userguide/getting-started.html#launch-region-shell
2 of 2
0
It sounds like you're encountering some common issues with Lambda layers. Let's go through a few potential reasons why your Lambda function might not be finding the correct folder for your dependencies: 1. Incorrect folder structure: When creating a layer for Python dependencies, the correct structure is crucial. The packages should be in a folder named 'python' at the root of your zip file, and within that, they should be in the appropriate site-packages directory. For example: python/lib/python3.x/site-packages/. 2. Python version mismatch: Ensure that the Python version you're using to install the packages matches the runtime of your Lambda function. If you're using Python 3.13 in your layer structure, make sure your Lambda function is also set to use Python 3.13. 3. Layer size limits: Lambda has a maximum size limit for all layers combined when extracted. If your layer is too large, it might not be applied correctly. 4. Layer attachment: Make sure you've actually attached the layer to your Lambda function after creating it. 5. Permissions: Ensure your Lambda function has the necessary permissions to access the layer. To troubleshoot: 1. Double-check your folder structure in the zip file. 2. Verify that the Python version in your layer matches your Lambda runtime. 3. Check the size of your layer - if it's very large, consider optimizing it. 4. Confirm that the layer is attached to your function. 5. Review the function's execution role to ensure it has permissions to use the layer. If you're still having issues, you might consider alternative approaches: 1. Include the dependencies directly in your Lambda deployment package instead of using a layer. 2. For larger dependencies, consider using Lambda container images, which have a much higher size limit (up to 10GB). Remember, while layers can be useful for managing dependencies, they're not always necessary. For simpler use cases, including dependencies directly in your deployment package can be more straightforward. **Sources** Unable to import module 'lambda_function': No module named 'requests | AWS re:Post Lambda Package Exceeds 60MB: Solutions for Large Dependencies? | AWS re:Post Packaging your layer content - AWS Lambda Lambda function package not found error | AWS re:Post
🌐
DEV Community
dev.to β€Ί rishabdugar β€Ί creating-aws-lambda-layers-for-python-runtime-a-complete-guide-3gi0
The Best Way to Create AWS Lambda λ Layers for Python 🐍 (Fast & Easy) : A Complete Guide - DEV Community
January 17, 2025 - To ensure compatibility, use pip’s --platform parameter to target AWS Lambda’s Linux environment: pip install ` --platform manylinux2014_x86_64 ` --target=layer/python ` --implementation cp ` --python-version 3.12 ` --only-binary=:all: --upgrade ` pandas numpy requests Β· This installs the dependencies directly into the layer/python directory, ready for packaging.
🌐
Medium
aws.plainenglish.io β€Ί easiest-way-to-create-lambda-layers-with-the-required-python-version-d205f59d51f6
Easiest Way to Create Lambda Layers with the Required Python Version | by Amit Duwal | AWS in Plain English
December 23, 2024 - A tutorial on using Amazon CloudShell to create lambda layers zip file. As a developer, I’ve always been excited about serverless computing and the potential it offers for scaling applications effortlessly. AWS Lambda, with its pay-as-you-go model, seemed like the perfect choice for my latest project. However, my enthusiasm was short-lived as I encountered a frustrating roadblock: adding external Python libraries to my Lambda functions.
🌐
DEV Community
dev.to β€Ί aws-builders β€Ί installing-python-dependencies-in-aws-lambda-easy-pip-guide-31o6
Installing Python dependencies in AWS Lambda: easy pip guide - DEV Community
March 31, 2025 - aws lambda publish-layer-version --layer-name python-requests-layer \ --zip-file fileb://python-requests.zip \ --compatible-runtimes python3.13 \ --compatible-architectures "arm64" Now, this layer will be available for us to use in our functions: This method allows for more complex and extensive dependencies inside your Lambda functions.
🌐
Serverless
serverless.com β€Ί blog β€Ί handling-aws-lambda-python-dependencies
Handling AWS Lambda Python Dependencies
April 21, 2022 - When we refer to β€œdependencies” we are talking about those libraries that are not available in the AWS Python Lambda runtime, for example β€œjsonpath_rw”
🌐
Astral
docs.astral.sh β€Ί uv β€Ί guides β€Ί integration β€Ί aws-lambda
Using uv with AWS Lambda - Astral Docs
January 15, 2026 - We'll then zip the dependencies in adherence with the expected layout for Lambda layers: $ mkdir python $ cp -r packages/lib python/ $ zip -r layer_content.zip python ... To generate deterministic zip archives, consider passing the -X flag to zip to exclude extended attributes and file system metadata. ... $ aws lambda publish-layer-version --layer-name dependencies-layer \ --zip-file fileb://layer_content.zip \ --compatible-runtimes python3.13 \ --compatible-architectures "x86_64"
🌐
Medium
medium.com β€Ί @dgomez.developer β€Ί aws-lambda-layers-creating-a-python-layer-with-custom-code-and-its-dependencies-for-using-it-in-8ec6f7528f5b
AWS lambda layers: Creating a Python layer with custom code and its dependencies for using it in all your Lambda functions | by Debora Gomez Bertoli | Medium
September 13, 2024 - In my case, I am using a monorepo for all my python lambda services but if you have each service/lambda in different repos this approach will work as well, you just need to follow the structure of the common library AWS lambda layer folder ( `common-lib`).
🌐
Medium
medium.com β€Ί @amarachi.ogu β€Ί installing-dependencies-for-aws-lambda-functions-using-layers-3a43bbe1831d
Installing Dependencies for AWS Lambda Functions Using Layers | by Amarachi Ogu | Medium
June 2, 2023 - In this blog post, we will walk through a simple method to install any required packages on Lambda using Layers. To demonstrate this, we will use AWS Cloud9 and install two dependencies: beautifulsoup4 and pandas.
🌐
Pybites
pybit.es β€Ί articles β€Ί guest-create-aws-lambda-layers
How to Create an AWS Lambda Layer For Any Python Dependency – Pybites
... In general, the idea is to setup a system that is identical or close to the system AWS Lambda Layers are based on, then install the dependencies with pip like in any other Python project, and finally ship these dependencies as a Lambda layer.
🌐
SysOpsTechnix
sysopstechnix.com β€Ί home β€Ί cloud β€Ί import python libraries for aws lambda layers
Import Python Libraries for AWS Lambda Layers
October 5, 2025 - When you add a layer to a lambda function, you have to specify the layer version and that will help you to backward compatibility with older versions of dependencies. Make your workload modular and easily deploy.
🌐
hatedabamboo notes
notes.hatedabamboo.me β€Ί lambda-pip-modules
Installing Python dependencies in AWS Lambda: easy pip guide
As a result, we get the following directory structure in our Lambda layer: bashlambda_layer/ β”œβ”€β”€ bin β”‚ β”œβ”€β”€ activate β”‚ β”œβ”€β”€ activate.csh β”‚ β”œβ”€β”€ activate.fish β”‚ β”œβ”€β”€ Activate.ps1 β”‚ β”œβ”€β”€ normalizer β”‚ β”œβ”€β”€ pip β”‚ β”œβ”€β”€ pip3 β”‚ β”œβ”€β”€ pip3.13 β”‚ β”œβ”€β”€ python -> python3 β”‚ β”œβ”€β”€ python3 -> /usr/bin/python3 β”‚ └── python3.13 -> python3 β”œβ”€β”€ include β”‚ └── python3.13 β”œβ”€β”€ lib β”‚ └── python3.13 β”‚ └── site-packages β”‚ β”œβ”€β”€ certifi β”‚ β”œβ”€β”€ certifi-2025.1.31.dist-info β”‚ β”œβ”€β”€ charse
🌐
AWS Cloud Community
docs.powertools.aws.dev β€Ί lambda β€Ί python β€Ί 2.16.2
Homepage - Powertools for AWS Lambda (Python)
June 6, 2023 - This helps us understand who uses ... for AWS Lambda languages. When using Layers, you can add Powertools for AWS Lambda (Python) as a dev dependency (or as part of your virtual env) to not impact the development process....