Pandas & AWS Lambda

前端 未结 11 901
太阳男子
太阳男子 2020-12-03 04:52

Does anyone have a fully compiled version of pandas that is compatible with AWS Lambda?

After searching around for a few hours, I cannot seem to find what I\'m looki

11条回答
  •  心在旅途
    2020-12-03 05:24

    I believe you should be able to use the recent pandas version (or likely, the one on your machine). You can create a lambda package with pandas by yourself like this,

    1. First find where the pandas package is installed on your machine i.e. Open a python terminal and type

      import pandas
      pandas.__file__
      

      That should print something like '/usr/local/lib/python3.4/site-packages/pandas/__init__.py'

    2. Now copy the pandas folder from that location (in this case '/usr/local/lib/python3.4/site-packages/pandas) and place it in your repository.
    3. Package your Lambda code with pandas like this:

      zip -r9 my_lambda.zip pandas/
      zip -9 my_lambda.zip my_lambda_function.py
      

    You can also deploy your code to S3 and make your Lambda use the code from S3.

    aws s3 cp  my_lambda.zip s3://dev-code//projectx/lambda_packages/
    

    Here's the repo that will get you started

提交回复
热议问题