firebase / firebase-admin-python

Firebase Admin Python SDK
https://firebase.google.com/docs/admin/setup
Apache License 2.0
1.03k stars 320 forks source link

Failed to import firestore #543

Closed phaolin10 closed 3 years ago

phaolin10 commented 3 years ago

Traceback (most recent call last): File "C:\Users\ismail\AppData\Local\Programs\Python\Python36\lib\site-packages\firebase_admin\firestore.py", line 22, in from google.cloud import firestore # pylint: disable=import-error,no-name-in-module File "C:\Users\ismail\AppData\Local\Programs\Python\Python36\lib\site-packages\google\cloud\firestore.py", line 18, in from google.cloud.firestore_v1 import version File "C:\Users\ismail\AppData\Local\Programs\Python\Python36\lib\site-packages\google\cloud\firestore_v1__init__.py", line 30, in from google.cloud.firestore_v1._helpers import GeoPoint File "C:\Users\ismail\AppData\Local\Programs\Python\Python36\lib\site-packages\google\cloud\firestore_v1_helpers.py", line 38, in from typing import ( ImportError: cannot import name 'NoReturn'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "c:/Users/ismail/Desktop/MobileQuery/MobileQuery/api/app.py", line 4, in from firebase_admin import firestore File "C:\Users\ismail\AppData\Local\Programs\Python\Python36\lib\site-packages\firebase_admin\firestore.py", line 28, in 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.

google-oss-bot commented 3 years ago

I found a few problems with this issue:

phaolin10 commented 3 years ago

from flask import Flask, json, request, jsonify import firebase_admin from firebase_admin import credentials from firebase_admin import firestore from google.cloud import firestore

app = Flask(name)

@app.route('/',methods=['GET']) def show_all(): cred = credentials.Certificate("./service_key.json") firebase_admin.initialize_app(cred)

db = firestore.client()

docs = db.collection('yellowtbs').where('tip_amount', "==", 2.26).stream()

list = []

for doc in docs:
    print("{} - {} \n".format(doc.id, doc.to_dict()))
    list.append(doc.id)
return "a"

app.run()

here is my code. when I try to run it gives the error like that. How can I solve this problem

hiranya911 commented 3 years ago

You probably need to upgrade your Python version. See following issues:

https://github.com/psf/black/issues/1666 https://github.com/beetbox/beets/issues/3143 https://stackoverflow.com/questions/65798315/importerror-cannot-import-name-noreturn-pytorch-on-macos-catalina

phaolin10 commented 3 years ago

I tried but it doesn't work. Does anyone have a better idea ?

hiranya911 commented 3 years ago

What exact version of Python did you try on?

phaolin10 commented 3 years ago

I tried 3.6.0 and 3.7.0 and finally resolve this problem with python 3.9.2 version.

Ppang0405 commented 2 years ago

Same when using python 3.10.1, using python 3.9.9 fixed it.