- Newest
- Most votes
- Most comments
Typical approach to create the layer would be as follows:
mkdir myproject
cd myproject
virtualenv v-env
source ./v-env/bin/activate
pip install pandas
deactivate
#Now creating layer #Make sure directory name is python nothing else
mkdir python
cd python
#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/* .
cd ..
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.
I was looking around to find best way of doing it as I also faced some issues using pandas with lambda functions. I followed the last option of using AWS Serverless Application Repository Console and it worked absolutely fine. I wasn’t aware of this, thanks for sharing.
@alok, glad it helped.
@rePost-User-6379718, curious, if any of the options suggested here worked for you? If not, what's the issue you are facing?
@rePost-User-6379718, If it didn't work for you let me know what are the challenges?
Hi,
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"
Thanks!
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.
Relevant content
- asked a year ago
- AWS OFFICIALUpdated 3 years ago
- AWS OFFICIALUpdated a month ago
- AWS OFFICIALUpdated 2 years ago
Hi rePost-User-6379718, If this answer helped, please accept the answer for better community experience. Thank you.