pythonfirebasegeopoints

NameError: name 'firebase' is not defined - Firestore GeoPoint


There are a lot of questions with similar title but I'm unable to figure out why firebase is not working. I've installed pip install --upgrade firebase-admin and everything is working fine but when I try to write GeoPoint I get this error on line:

position = firebase.firestore.GeoPoint(38.895242, -77.031256)

The error is:

NameError: name 'firebase' is not defined

I've imported

import firebase_admin
from firebase_admin import credentials
from firebase_admin import firestore
import os

Solution

  • Do:

    import firebase
    

    You are getting the error because you didn't import firebase and Python can't find it in its namespace.

    Better still, do:

    position = firestore.GeoPoint(38.895242, -77.031256)
    

    This is because you already imported firestore.