Error when building Python Lambda function
Hi,
I'm triyng to build my Python Lambda function and I'm getting the following error:
Starting Build use cache
Manifest file is changed (new hash: 967db893d1675e23520f60870b0b85cb) or dependency folder (.aws-sam\deps\2751134e-8ae2-42f9-a415-0b85fbd4e4ee)
is missing for (CheckerFunction, SplitterFunction, PublisherFunction, ConsumerFunction, DeadLetterHandlerFunction), downloading dependencies and
copying/building source
Building codeuri: C:\Users\jmuno\Desktop\aws-s3_batch_upload\functions runtime: python3.11 metadata: {} architecture: x86_64 functions:
CheckerFunction, SplitterFunction, PublisherFunction, ConsumerFunction, DeadLetterHandlerFunction
Running PythonPipBuilder:CleanUp
Running PythonPipBuilder:ResolveDependencies
Build Failed
Error: PythonPipBuilder:ResolveDependencies - {numpy==2.3.5(wheel), pandas==2.3.3(wheel)}
The error is related to pandas, but I don't know what it is. This is my requirement.txt.
pandas
python-dotenv
boto3
requests
And this is part of my template.yaml.
Runtime: python3.11
Architectures:
- x86_64
Can you give a hand?
Regards
- Topics
- ServerlessCompute
- Tags
- AWS Lambda
- Language
- English
- Newest
- Most votes
- Most comments
It looks like you're encountering an issue with package dependencies when building your Python Lambda function. The error is occurring during the dependency resolution phase of your build process.
The specific error relates to numpy and pandas wheel packages. The issue is likely due to compatibility problems between the versions being installed. The error message shows it's trying to use numpy==2.3.5 and pandas==2.3.3, but numpy 2.3.5 doesn't exist (the latest stable version is around 1.26.x as of writing).
Here are some solutions to try:
- Pin specific compatible versions in your requirements.txt file:
pandas==2.0.3
numpy==1.24.3
python-dotenv
boto3
requests
-
Make sure you're building your Lambda package in an environment that matches the Lambda runtime (Python 3.11 in your case). Architecture mismatches can cause compiled extensions to fail.
-
Consider using Lambda Layers for large dependencies like pandas and numpy to reduce your deployment package size.
-
If you're using a local development environment that differs from the Lambda runtime, try using a Docker container that matches the Lambda environment for building your package.
These steps should help resolve the dependency resolution error you're experiencing with pandas and numpy.
Sources
Troubleshooting - Powertools for AWS Lambda (Python)
Troubleshooting - Powertools for AWS Lambda (Python)
answered 7 months ago
It is essentially trying to download the latest panda and numpy versions as dependencies which are not compatible to Python 11 Lambda runtime. You need to pin the version number in requirements.txt file and use a lower version.
pandas==2.1.4
numpy==1.26.4
python-dotenv
boto3
requests
