Rus*_*ord 6 python numpy amazon-web-services aws-lambda
我正在尝试将我的 python 代码上传到 AWS Lambda。我一直在按照本指南创建部署包 ( https://docs.aws.amazon.com/lambda/latest/dg/lambda-python-how-to-create-deployment-package.html )。
我在桌面上创建了一个文件夹“project-dir”,并将我的 python 文件“Twilio_Alerts_AWS.py”移动到该文件夹中。我使用了以下命令:
pip install module-name -t /path/to/project-dir
Run Code Online (Sandbox Code Playgroud)
将我所有的库安装到该文件夹中。接下来,我突出显示所有内容并通过右键单击文件夹中突出显示的文件来点击“压缩”。这会生成一个名为“存档”的压缩文件
我将'archive.zip'它放在 AWS 上的 S3 存储桶中,并将其调用到 AWS Lambda 中。Unable to import module 'Twilio_Alerts_AWS': Missing required dependencies ['numpy']
即使我已将 numpy 安装到文件夹中,我仍然收到错误消息。
不知道我做错了什么。
我正在尝试上传的代码:
from twilio.rest import Client
import time
import datetime
import requests
import pandas as pd
from pandas.io.json import json_normalize
def lambda_handler(event, context):
# Your Account SID from twilio.com/console
account_sid = "xxx"
# Your Auth Token from twilio.com/console
auth_token = "xxx"
client = Client(account_sid, auth_token)
current_datetime = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
headers = {
'Accept': 'application/json',
'Content-Type': 'application/json',
'x-api-key': 'xxx',
'x-organization-id': 'xxx',
'x-facility-id': 'xxx',
'x-user-id': 'xxx',
}
orders_staging_api_call = requests.get('URL', headers=headers, verify=False)
consumers_staging_api_call = requests.get('URL', headers=headers, verify=False)
inventory_staging_api_call = requests.get('URL', headers=headers, verify=False)
lst = ["+1234567890"]
##Consumers API Alert
if consumers_staging_api_call.status_code !=200:
for i in lst:
message = client.messages.create(
to=i,
from_="+1234567890",
body="API connection between A and B has failed for: Consumers.Datetime of check:{}".format(current_datetime))
time.sleep(5)
print(message.sid)
else:
print('done')
Run Code Online (Sandbox Code Playgroud)
编辑:使用 osx 机器。
小智 8
这里的答案对我有帮助:AWS lambda 中的 Pandas 给出了 numpy error。
TLDR:在 mac 上编译的库不能在 linux 上运行,因此您需要确保以一种或另一种方式获得 linux 版本(例如 Docker)。
| 归档时间: |
|
| 查看次数: |
9036 次 |
| 最近记录: |