I had the same issue and I have solved with similar approach to the previous answers (x86_64)
--platform linux_x86_64 --only-binary=:all:
if you want to build the package locally and then deploy it to lambda
pip install -r requirements.txt -t ./package --platform linux_x86_64 --only-binary=:all:
If you want to create a lambda layer you can use this docker example:
virtualenv --python=/usr/bin/python3.13 python
source python/bin/activate
pip install -r requirements.txt -t python/lib/python3.13/site-packages --platform linux_x86_64 --only-binary=:all:
zip -r9 python.zip python
and then use the generated zip to upload as a lambda layer
Upload the zip to a s3 bucket:
aws s3 cp <local_folder>/ <s3_bucket_dependency_folder> --recursive
publish layer:
lambda publish-layer-version --layer-name <lambda_layer_name> \
--description <lambda_layer_description> \
--content S3Bucket=<s3_bucket>,S3Key=<path_to_file> \
--compatible-runtimes python3.13 \
Add permission to other aws envs to use this layer (if needed)
aws lambda add-layer-version-permission \
--layer-name <lambda_layer_name> \
--version-number <lambda_layer_version> \
--statement-id shareWithTEST \
--principal <aws_account_id> \
--action lambda:GetLayerVersion
requirrments.txt?pip install fastapiletsimport pydanticandimport pydantic_core._pydantic_corerun just fine. In fact the error might be caused by explicitly including pydantic (with a v1 version?) in the dependencies, but can't really say without further info. @krish___na please can you make a new question with more info, this one gives no details on how the packages are installed, so it's hard to reproduce your problem, and comments aren't appropriate for describing separate cases.