AWS Lambda Layer Python Installation issues #1467
Replies: 1 comment
-
|
Hi @Kowareyasuki! 👋 This is a common issue with Lambda layers and pydantic. Here are some solutions: Issue 1: Old version installingTo ensure you get the latest version, explicitly specify it: pip install "strands-agents>=1.21.0" --python-version 3.12 --platform manylinux2014_aarch64 --target ./packaging/_dependencies --only-binary=:all:Or create a Issue 2: pydantic_core import errorThe
# For arm64 Lambda
pip install strands-agents --python-version 3.12 --platform manylinux2014_aarch64 --target ./python --only-binary=:all:
docker run --rm -v $(pwd):/var/task public.ecr.aws/sam/build-python3.12:latest \
pip install strands-agents -t /var/task/pythonRecommended ApproachFor reliable Lambda layers, use AWS SAM or CDK with Docker builds. Example with Docker: FROM public.ecr.aws/sam/build-python3.12:latest
RUN pip install strands-agents -t /opt/pythonThis ensures all native extensions (like pydantic_core) are compiled for the correct Lambda runtime. Let me know if you're still having issues! 🦆 🤖 This is an experimental AI agent response from the Strands team, powered by Strands Agents. We're exploring how AI agents can help with community support and development. Your feedback helps us improve! If you'd prefer human assistance, please let us know. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi guys, I want to install Strands as a layer for my aws lambda but what happen is when i follow this documentation on installing strands and zipping it, it installs the old version of strands sdk to v1.1 which prevents me from using most of the latest changes.
the instruction i followed came from this one: https://github.com/strands-agents/docs/tree/main/docs/examples/cdk/deploy_to_lambda
where i just use
pip install -r requirements.txt --python-version 3.12 --platform manylinux2014_aarch64 --target ./packaging/_dependencies --only-binary=:all:now it installs the old version (v1.1) which prevents me from using the new systemcontentblock feature and stuffs i coded for latest sdk.
and i followed this step and used arm64 lambda: https://github.com/strands-agents/docs/blob/main/docs/user-guide/deploy/deploy_to_aws_lambda.md
this is the new error i get but i can confirm i have pydantic core exist in the zip file.
Status: Failed
Test Event Name: sample
Response:
{
"errorMessage": "Unable to import module 'lambda_function': No module named 'pydantic_core._pydantic_core'",
"errorType": "Runtime.ImportModuleError",
"requestId": "",
"stackTrace": []
}
Is there a way to Install the latest sdk version? thank you!
Beta Was this translation helpful? Give feedback.
All reactions