I am new to Python and Pyrebase4. When I created my firebaseConfig
after pip install pyrebase4
, I ran it just to check whether its working or not and it gave me this Traceback
Traceback (most recent call last):
File "D:\Python Projects\FirebaseTesting\main.py", line 14, in <module>
firebase = pyrebase.initialize_app(firebaseConfig)
File "D:\Python Projects\FirebaseTesting\venv\lib\site-packages\pyrebase\pyrebase.py", line 28, in initialize_app
return Firebase(config)
File "D:\Python Projects\FirebaseTesting\venv\lib\site-packages\pyrebase\pyrebase.py", line 34, in __init__
self.api_key = config["apiKey"]
TypeError: 'set' object is not subscriptable
Here is My Code:
import pyrebase
firebaseConfig = { 'apiKey:' "xxx",
'authDomain:' "xxx.firebaseapp.com",
'databaseURL:' "https://xxx-default-rtdb.firebaseio.com",
'projectId:' "xxx",
'storageBucket:' "xxx.appspot.com",
'messagingSenderId:' "xxx",
'appId:' "xxx",
'measurementId:' "xxx"}
firebase = pyrebase.initialize_app(firebaseConfig)
Please Help Me Out! It would be greatly helpful
Thanks
Programmer_Steve
This should fix your problem:
firebaseConfig = { 'apiKey': "xxx",
'authDomain': "xxx.firebaseapp.com",
'databaseURL': "https://xxx-default-rtdb.firebaseio.com",
'projectId': "xxx",
'storageBucket': "xxx.appspot.com",
'messagingSenderId': "xxx",
'appId': "xxx",
'measurementId': "xxx"}
Notice that :
is outside!!
What you were doing is like this: a = {"a:", "b", "c:", "d"}
, and this is called a set in Python. I'm pretty sure you were trying to create a dictionary, and a dictionary can be created like this: a = {"a": "b", "c": "b"}
.
Can you see the difference?
The difference is that you were putting :
inside "
, and Python thinks :
is part of the string.