ModuleNotFoundError: 没有名为“Crypto”或“Pyrebase”的模块

时间:2021-04-30 14:40:23

标签: python

File "login_main.py", line 7, in <module>
       import pyrebase
    File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\site-packages\pyrebase\__init__.py", line 1, in <module>
    from .pyrebase import initialize_app
  File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\site-packages\pyrebase\pyrebase.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_()

1 个答案:

答案 0 :(得分:0)

这样做(Windows)

pip install pycryptodome

Linux

sudo apt-get install python3 python3-pip
pip3 install pycryptodome

第一行只是为了确保安装python3和pip3和/或升级到最新版本并确保python脚本在PATH

测试安装使用 Linux

python3 -m Crypto.SelfTest

视窗

py -m Crypto.SelfTest
相关问题