AWS Lambda到Firestore错误:无法导入名称"cygrpc" [英] AWS Lambda to Firestore error: cannot import name 'cygrpc'

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

问题描述

在我的AWS Lambda Python 3.6函数上,我想使用Google Firestore(Cloud Firestore BETA)进行缓存,但是一旦添加

from google.cloud import firestore

到我的Python脚本并将ZIP上载到AWS Lambda函数,Lambda测试返回错误

Unable to import module 'MyLambdaFunction': cannot import name 'cygrpc'. 

AWS CloudWatch日志不包含有关该错误的任何详细信息,仅包含相同的错误消息.

Lambda函数在我的本地开发机(Windows 10)上运行良好,并且可以很好地写到Firestore.如果我将导入和所有与Firestore相关的行注释掉,它也可以在AWS上使用.

有什么技巧可以解决这个问题吗?

解决方案

Firestore的python客户端依赖于基于C的GRPC实现.默认情况下,这似乎在AWS Lambda中不起作用.

Node.js用户报告了类似的问题,并且他们记录了构建docker的解决方法图片.

这应该与获取需要本机代码才能工作的任何其他python包相似.也许像这样的方法可以使 scikit正常工作?

我希望这足以使您朝正确的方向前进,但是不幸的是,我对AWS Lambda并不了解:-(.

On my AWS Lambda Python 3.6 function I'd like to use Google Firestore (Cloud Firestore BETA) for caching purposes, but as soon as I add

from google.cloud import firestore

to my Python script and upload ZIP to AWS Lambda function, Lambda test come back with error

Unable to import module 'MyLambdaFunction': cannot import name 'cygrpc'. 

AWS CloudWatch log doesn't contain any details on the error, just that same error message.

Lambda function works great on my local dev machine (Windows 10), and I can write to Firestore fine. It also works on AWS if I comment out the import and all Firestore related lines.

Any tips how I could go about solving this?

解决方案

The python client for Firestore relies on the C-based implementation of GRPC. This appears not to work by default in AWS Lambda.

Node.js users have reported similar problems and they've documented a workaround of building a docker image.

This should be similar to any getting any other python package that requires native code to work. Perhaps something like this method for getting scikit to work?

I hope this is enough to get you going in the right direction, but unfortunately I don't know anything about AWS Lambda :-(.

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

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