【发布时间】:2019-06-20 01:35:18
【问题描述】:
我正在尝试在我现有的无服务器 AWS Lambda 应用程序中使用 Google Cloud Firestore。
这就是我所做的。
我在 requirements.txt 中添加了库(google-cloud-firestore) 我已经完成了所需的设置并添加了 creds json 文件。 我正在使用“serverless-python-requirements”和 docker 部署进行应用程序部署。
我可以在我的本地环境中运行一切正常,但是当我在 AWS lambda 上部署它时,我收到以下错误。
module initialization error: The 'google-cloud-firestore' distribution was not found and is required by the application
我尝试了很多。我什至尝试过 fork google cloud python repo 并设置调用 pkg_resources.get_distribution 的静态值。这似乎有效,但不是正确的解决方案。
这是分叉和编辑的链接。 https://github.com/AmitChotaliya/google-cloud-python/commit/f23539f0905721f2b1b11d2439e351d438f541dd#diff-5e99793fe69a94f0f27267a2fba86306
【问题讨论】:
-
您是否将包上传到 Lambda?请参阅:docs.aws.amazon.com/lambda/latest/dg/… 看起来不只是将其添加到 requirements.txt 就足够了
-
@jhomr,是的,我已经做到了。我已经在使用其他自定义 pip 包,如烧瓶、simplejson、razorpay 等。它们运行良好。只有谷歌图书馆不工作。
标签: python aws-lambda google-cloud-firestore serverless-framework