VOOZH about

URL: https://repost.aws/questions/QUfcZ7BSQHRQadjyIsav3v5g/error-when-building-python-lambda-function

⇱ Error when building Python Lambda function | AWS re:Post


Skip to content

Error when building Python Lambda function

0

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

Language
English

asked 7 months ago311 views

2 Answers
  • Newest
  • Most votes
  • Most comments
Are these answers helpful? Upvote the correct answer to help the community benefit from your knowledge.
0
Accepted Answer
This recommendation was generated using AWS Generative AI capabilities. You are responsible for evaluating the recommendation in your specific context and implementing appropriate oversight and safeguards. Learn more

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:

  1. Pin specific compatible versions in your requirements.txt file:
pandas==2.0.3
numpy==1.24.3
python-dotenv
boto3
requests
  1. 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.

  2. Consider using Lambda Layers for large dependencies like pandas and numpy to reduce your deployment package size.

  3. 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

EXPERT

reviewed 7 months ago

0

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
EXPERT

answered 7 months ago