Typical approach to create the layer would be as follows:
pip install pandas
#Now creating layer #Make sure directory name is python nothing else
#Just check the list-packages or site-packages path one directory above and update accordingly on next command
cp -r ../v-env/lib64/python3.10/dist-packages/* .
zip -r pandas_layer.zip python
#Create layer through CLI or Console #Keep compatible run time from python 3.7 to 3.10 and lambda run time as python 3.10
There are few pointers which may help you in this case:
First: If you are using mac for creating pandas package, try ubuntu or linux(most of times this helps)
Second: Try deploying the function and package in python3.10 at local and then upload it in AWS
Third: if you are familiar with CI/CD, best to deploy with codepipeline where AWS would create docker environment and install pandas library along with it's dependency(pytz, numpy, tzdata) through requirements.txt where you would specify pandas==1.2.3(example)
Lastly(best if not using CI/CD): Follow this post step by step https://repost.aws/knowledge-center/lambda-python-function-layer and deploy the lambda function separately without pandas package zipped with it and update the layer for this lambda, which would be created following above post.
There are multiple other options than creating the layer, to add Pandas in the Lambda layer:
- Directly use the Pandas library ARN from this repository: https://github.com/keithrozario/Klayers/tree/master/deployments/python3.10
- You could use the default Lambda layer "AWSDataWrangler"
Take a look at using a Lambda layer for pandas to see if it fits your use case. https://aws-sdk-pandas.readthedocs.io/en/stable/layers.html has a good summary of layers available.
- AWS OFFICIALUpdated 8 months ago
- AWS OFFICIALUpdated 10 months ago
- How do I resolve the "Unable to import module" error that I receive when I run Lambda code in Python?AWS OFFICIALUpdated 9 months ago
- AWS OFFICIALUpdated a year ago
- EXPERTpublished 5 months ago
- EXPERTpublished a year ago