12

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

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
Anubhav Dhawan
  • 1,431
  • 6
  • 19
  • 35
  • Try installing `google-cloud-firestore` instead of (or in addition to?) `firebase-admin`, as per the error message. – Dan Cornilescu Jan 15 '18 at 16:17
  • Sometimes the dev appserver has issues loading `google.*` modules from the local `lib/` directory. If the modules are indeed installed correctly, try something like the solution described [here](https://github.com/GoogleCloudPlatform/google-auth-library-python/issues/169#issuecomment-315417916). – Hiranya Jayathilaka Jan 16 '18 at 02:19
  • Did this get resolved? – kashiB Mar 08 '19 at 07:09

4 Answers4

11

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

Chayapol
  • 3,718
  • 1
  • 21
  • 12
7

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
MAGA PILL
  • 91
  • 1
  • 5
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
    
2

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