【问题标题】:ImportError: Failed to import the Cloud Firestore library for PythonImportError:无法导入适用于 Python 的 Cloud Firestore 库
【发布时间】:2018-06-24 04:12:21
【问题描述】:

尝试在 python 服务器上集成 Google firestore API

...
  File "/home/daffolap-355/repos/subscriptions/appvendor/firebase_admin/firestore.py", line 28, in <module>
    raise ImportError('Failed to import the Cloud Firestore library for Python. Make sure '
ImportError: Failed to import the Cloud Firestore library for Python. Make sure to install the "google-cloud-firestore" module.

我在这里收到此错误:

from firebase_admin import credentials, auth, firestore

我安装了firebase-admin 模块:

pip install --upgrade -t libs firebase-admin

然后运行应用程序

dev_appserver app.yaml

【问题讨论】:

  • 尝试安装google-cloud-firestore,而不是(或除了?)firebase-admin,根据错误消息。
  • 有时开发应用服务器在从本地 lib/ 目录加载 google.* 模块时遇到问题。如果确实正确安装了模块,请尝试类似here 描述的解决方案。
  • 解决了吗?

标签: python firebase google-app-engine google-cloud-firestore firebase-admin


【解决方案1】:

我在 Windows 上安装 firebase_admin 库时遇到了类似的问题。 解决方案是将 protobuf 库降级到 3.6.0。

pip install protobuf==3.6

【讨论】:

    【解决方案2】:

    Google Cloud Firestore 需要 grpc

    pip install grpcio
    

    但是,根据您的操作系统,还有其他步骤。退房 https://github.com/grpc/grpc/tree/master/src/python/grpcio

    【讨论】:

      【解决方案3】:

      这对我有用。 尝试卸载并重新安装 google-cloud-firestore

      1. 使用 pip 卸载“google-cloud-firestore”

           pip uninstall google-cloud-firestore
        
      2. 再次使用 pip 重新安装它

           pip install google-cloud-firestore
        

      【讨论】:

        【解决方案4】:

        要解决“google-cloud-firestore”模块错误,请执行以下操作:

        • pip install google-cloud-core
        • pip install google-cloud-firestore

        然后像这样导入:

        • 导入操作系统
        • 导入 firebase_admin
        • 从 firebase_admin 导入 凭据
        • 从 google.cloud 导入 firestore
        • 来自 firebase_admin 导入火库

        【讨论】:

          猜你喜欢
          • 2021-12-06
          • 2021-01-01
          • 1970-01-01
          • 2022-01-23
          • 2020-09-09
          • 2020-01-23
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多