【问题标题】:Google Firestore python library not working in AWS LambdaGoogle Firestore python 库在 AWS Lambda 中不起作用
【发布时间】: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


【解决方案1】:

我找到了解决方案。这是我做错的地方。

我使用的是无服务器框架,我正在使用“serverless-python-requirements”和 docker 部署来部署应用程序。

我的配置如下

custom:
  wsgi:
    app: app.app
    packRequirements: false
  pythonRequirements:
    dockerizePip: non-linux
    slim: true

问题出在slim: true,它排除了.so 文件。我删除了它,它工作正常。

【讨论】:

    猜你喜欢
    • 2023-03-26
    • 2020-06-21
    • 2020-12-02
    • 2019-06-19
    • 2021-08-19
    • 1970-01-01
    • 1970-01-01
    • 2018-12-19
    • 1970-01-01
    相关资源
    最近更新 更多