File "login_main.py", line 7, in <module>
import pyrebase
File "C:UsersuserAppDataLocalProgramsPythonPython38libsite-packagespyrebase__init__.py", line 1, in <module>
from .pyrebase import initialize_app
File "C:UsersuserAppDataLocalProgramsPythonPython38libsite-packagespyrebasepyrebase.py", line 23, in <module>
from Crypto.PublicKey import RSA
ModuleNotFoundError: No module named 'Crypto'
发生错误。我现在能做什么?
import sys
from PyQt5 import QtWidgets,QtCore
from PyQt5.QtCore import *
from PyQt5.QtWidgets import QDialog, QApplication
from PyQt5.uic import loadUi
import pyrebase
firebaseConfig = {
'apiKey': "AIzaSyA18bMokpiDFV1-SHNVBDsrd2ARIBGFPE4",
'authDomain': "face-database-26e72.firebaseapp.com",
'projectId': "face-database-26e72",
'storageBucket': "face-database-26e72.appspot.com",
'messagingSenderId': "290330231043",
'appId': "1:290330231043:web:e93a1f26cf36c5b971a936",
'measurementId': "G-HP1XBP31VJ"
}
firebase = pyrebase.initalize_app(firebaseConfig)
auth = firebase.auth()
登录并创建代码:
class Login(QDialog):
def __init__(self):
super(Login,self).__init__()
loadUi("login.ui",self)
self.loginbutton.clicked.connect(self.loginfunction)
self.password.setEchoMode(QtWidgets.QLineEdit.Password)
self.create.clicked.connect(self.gotocreate)
def loginfunction(self):
username = self.username.text()
password = self.password.text()
print("Successfully login in with email : ",username," and password : ",password)
def gotocreate(self):
createButton = CreateAcc()
widget.addWidget(createButton)
widget.setCurrentIndex(widget.currentIndex()+1)
class CreateAcc(QDialog):
def __init__(self):
super(CreateAcc,self).__init__()
loadUi("sinup.ui",self)
self.create.clicked.connect(self.createaccfuntion)
self.password.setEchoMode(QtWidgets.QLineEdit.Password)
self.config_password.setEchoMode(QtWidgets.QLineEdit.Password)
def createaccfuntion(self):
username = self.username.text()
if self.password.text() == self.config_password.text():
password = self.password.text()
auth.create_user_with_email_and_password(username,password)
login = Login()
widget.addWidget(login)
widget.setCurrentIndex(widget.currentIndex()+1)
主代码
if __name__ == "__main__":
app = QApplication(sys.argv)
mainwindow = Login()
widget = QtWidgets.QStackedWidget()
widget.addWidget(mainwindow)
widget.setFixedWidth(480)
widget.setFixedHeight(720)
widget.setWindowFlag(QtCore.Qt.FramelessWindowHint)
widget.setAttribute(QtCore.Qt.WA_TranslucentBackground)
widget.show()
app.exec_()
Do this(Windows(
pip install pycryptodome
Linux
sudo apt-get install python3 python3-pip
pip3 install pycryptodome
第一行只是确保安装python3和pip3和/或升级到最新版本,并确保python脚本在PATH
中
使用测试安装Linux
python3 -m Crypto.SelfTest
Windows
py -m Crypto.SelfTest