无法为AWS Lambda导入grequest [英] Unable to import grequests for AWS Lambda

查看:161
本文介绍了无法为AWS Lambda导入grequest的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行带有Python 2.7运行时的AWS Lambda脚本.但是,无论何时初始化,它都会开始导入grequests库,但是由于依赖于gevent而失败:

Gevent is required for grequests.

似乎可以成功找到grequests库(因为它知道需要gevent),但是失败了.

到目前为止我已经尝试过的:

pip install --ignore-installed grequests -t .

pip install --ignore-installed grequests -t ./lib

pip install --ignore-installed gevent -t .

pip install --ignore-installed gevent -t ./lib

然后,我压缩目录的内容并按照此处的说明上载到AWS:解决方案

我必须在Amazon Linux实例上从src构建gevent.如果有人需要,我会将结果文件放在zip中-只需将它们包含在上载的Lambda zip中,您就应该像老板一样并发操作.

https://github.com/brandonmp/aws-lambda-grequests

I'm running an AWS Lambda script with a Python 2.7 runtime. However, whenever it initializes it begins to import the grequests library but fails because of it's dependency on gevent:

Gevent is required for grequests.

It seems it is successfully finding the grequests library (since it knows it needs gevent) but fails.

What I've tried so far:

pip install --ignore-installed grequests -t .

pip install --ignore-installed grequests -t ./lib

pip install --ignore-installed gevent -t .

pip install --ignore-installed gevent -t ./lib

And then I compress the contents of the directory and upload to AWS per the instructions here: http://docs.aws.amazon.com/lambda/latest/dg/lambda-python-how-to-create-deployment-package.html

It seems no matter what I try the Lambda is unable to locate gevent, but it's able to find other non-default libraries with no issue.

解决方案

I had to build gevent from src on an Amazon Linux instance. I put the resultant files in a zip if anyone needs them--just include them in your uploaded Lambda zip and you should be concurrent-ing like a boss.

https://github.com/brandonmp/aws-lambda-grequests

这篇关于无法为AWS Lambda导入grequest的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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