ImportError:无法为Python导入Cloud Firestore库

Anu*_*wan 7 python google-app-engine firebase firebase-admin google-cloud-firestore

尝试在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.
Run Code Online (Sandbox Code Playgroud)

我在这里收到此错误:

from firebase_admin import credentials, auth, firestore

我安装了firebase-admin模块:

pip install --upgrade -t libs firebase-admin

并运行应用

dev_appserver app.yaml

Cha*_*pol 6

Google Cloud Firestore要求grpc

pip install grpcio
Run Code Online (Sandbox Code Playgroud)

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


小智 5

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

  • pip 安装谷歌云核心
  • pip 安装 google-cloud-firestore

然后像这样导入:

  • 导入操作系统
  • 导入 firebase_admin
  • 从 firebase_admin 导入凭据
  • 从 google.cloud 导入 Firestore
  • 从 firebase_admin 导入 firestore