【问题标题】:External lib not found when deploy on Google App Engine在 Google App Engine 上部署时找不到外部库
【发布时间】:2017-05-28 12:52:21
【问题描述】:

为了在 Python + GAE 应用程序中使用 firebase 进行身份验证,我使用了几个 google 库。 我已经为 requirements.txt 配置了以下内容:

google-auth==1.0.1
requests==2.14.2
requests-toolbelt==0.7.1

这是我要导入的:

import google.auth.transport.requests

当我运行 pip install 时,它们会在本地安装并且我没有收到任何错误。

local libs screenshot


但是当我尝试将此应用程序部署到 Google App Engine 时,所有这些外部库都会出现相同的错误。 GAE 没有找到文件:

ImportError: No module named auth.transport.requests

【问题讨论】:

    标签: python google-app-engine


    【解决方案1】:

    您需要将您的库目录提供给google.appengine.ext.vendor.add() 方法。

    在与您的 app.yaml 文件相同的文件夹中创建一个名为 appengine_config.py 的文件。

    编辑 appengine_config.py 文件并将您的库目录提供给 vendor.add() 方法。

    # appengine_config.py
    from google.appengine.ext import vendor
    
    # Add any libraries installed in the "lib" folder.
    vendor.add('lib')
    

    https://cloud.google.com/appengine/docs/standard/python/tools/using-libraries-python-27#installing_a_third-party_library

    【讨论】:

      猜你喜欢
      • 2017-12-24
      • 2015-02-19
      • 2018-09-07
      • 2020-10-14
      • 2021-12-30
      • 2011-03-20
      • 2018-12-16
      相关资源
      最近更新 更多