简体   繁体   中英

module 'pyrebase' has no attribute 'initialize_app'

I currently use streamlit and wanted to integrate to firebase. I have been encountered the problem "no module named 'pyrebased'" and finally can install it.

however I face another problem said that " module 'pyrebase' has no attribute 'initialize_app'"

this what I encounter in the streamlit local host

在此处输入图像描述

and here is my code

# ------ Modules
import pyrebase
import streamlit as st
from datetime import datetime

#------ Configuration Key
firebaseConfig = {
  'apiKey': "AIzaSyBvTe3A9M0R0HDaumOHhw_knSTEYqSmnio",
  'authDomain': "gnseastreamlit1.firebaseapp.com",
  'projectId': "gnseastreamlit1",
  'databaseURL' : "https://console.firebase.google.com/u/0/project/gnseastreamlit1/database/gnseastreamlit1-default-rtdb/data/~2F",
  'storageBucket': "gnseastreamlit1.appspot.com",
  'messagingSenderId': "263267683418",
  'appId' : "1:263267683418:web:549f4369140beb80e95c63",
  'measurementId': "G-33QXY92WQG"
}

# ------ Firebase Authentication
firebase = pyrebase.initialize_app(firebaseConfig)
auth = firebase.auth()

# ------ Database
db = firebase.database()
storage = firebase.storage()

Save your project file in the same folder which has pyrebase package installed

Source: https://github.com/thisbejim/Pyrebase/issues/66

Could you try: pip install pyrebase4

Did you make sure you installed the right version of Pyrebase? I had some errors when I ran pip install pyrebase . However, I found out that I actually needed to run pip install pyrebase4 for it to work as shown in this post about pyrebase and fastAPI for authentication.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM