ImportError: Failed to import the Cloud Firestore library for Python

孤者浪人 提交于 2019-12-01 15:45:38

问题


Trying to integrate Google firestore API at python server

...
  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.

I get this error here:

from firebase_admin import credentials, auth, firestore

I installed the firebase-admin module:

pip install --upgrade -t libs firebase-admin

And run the app

dev_appserver app.yaml


回答1:


Google Cloud Firestore requires grpc.

pip install grpcio

However, there are additional steps depending on your OS. Check out https://github.com/grpc/grpc/tree/master/src/python/grpcio




回答2:


To solve the "google-cloud-firestore" module error do this:

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

And then import like this:

  • import os
  • import firebase_admin
  • from firebase_admin import credentials
  • from google.cloud import firestore
  • from firebase_admin import firestore



回答3:


This worked for me. Try uninstalling and re-installing google-cloud-firestore

  1. Uninstall "google-cloud-firestore" using pip

       pip uninstall google-cloud-firestore
    
  2. Re-install it using pip again

       pip install google-cloud-firestore
    



回答4:


I faced similar issue when installing firebase_admin library on windows. The solution was to downgrade protobuf library to 3.6.0.

pip install protobuf==3.6


来源:https://stackoverflow.com/questions/48264536/importerror-failed-to-import-the-cloud-firestore-library-for-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!