0

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

1
  • Did you solve your problem? Commented Jan 3, 2022 at 23:35

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

Comments

1

The error message is of course correct, set objects aren't subscriptable. But dictionaries are, and they're very similar. In your case you made the very simple mistake of putting the : inside the string instead of outside, resulting in a set when you wanted a dictionary.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.