AWS Lambda中的 pandas 给出了numpy错误 [英] Pandas in AWS lambda gives numpy error

查看:203
本文介绍了AWS Lambda中的 pandas 给出了numpy错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直试图在导入熊猫的AWS Lambda中运行我的代码.这就是我所做的. 我有一个python文件,其中包含以下简单代码(此文件具有lambda处理程序)

I've been trying to run my code in AWS Lambda which imports pandas. So here is what I've done. I have a python file which contains a simple code as follows(This file has the lambda handler)

import json
print('Loading function')
import pandas as pd
def lambda_handler(event, context):
    return "Welcome to Pandas usage in AWS Lambda"

  1. 我已将此python文件以及numpy,pandas和pytz库压缩为部署包(所有这些文件都已存储在Amazon EC2 linux计算机中)
  2. 然后将包上传到S3
  3. 创建了一个lambda函数(运行时= python3.6),并从S3上传了部署程序包

但是当我在AWS Lambda中测试lambda函数时,出现以下错误:

But when I test the lambda function in AWS Lambda, I get the below error:

Unable to import module 'lambda_function': Missing required dependencies ['numpy']

我在压缩包中已经有numpy了,但是仍然出现此错误.我尝试遵循 Pandas& AWS Lambda ,但没有运气.

I already have numpy in the zipped package but still I get this error. I tried to follow the hints given at Pandas & AWS Lambda but no luck.

有人遇到过同样的问题吗?希望能有解决此问题的任何提示或建议.

Did anyone ran into the same issue. Would appreciate any hint or suggestions to solve this problem.

谢谢

推荐答案

我终于弄清楚了如何运行pandas& AWS Lambda python 3.6运行时环境中的numpy.

I figured out finally how to run pandas & numpy in a AWS Lambda python 3.6 runtime environment.

我已将部署程序包上传到以下存储库:

I have uploaded my deployment package to the following repo:

git clone https://github.com/pbegle/aws-lambda-py3.6-pandas-numpy.git

只需运行以下命令即可将lambda_function.py添加到zip文件中:

Simply add your lambda_function.py to the zip file by running:

zip -ur lambda.zip lambda_function.py

上传到S3并将其源到lambda.

Upload to S3 and source to lambda.

原始:

我让熊猫在lambda函数中工作的唯一方法是按照

The only way I have gotten Pandas to work in a lambda function is by compiling the pandas (and numpy) libraries in an AWS Linux EC2 instance following the steps from this blog post and then using the python 2.7 runtime for my lambda function.

这篇关于AWS Lambda中的 pandas 给出了numpy错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆