加载泡菜时,出现导入错误,“没有名为sip的模块”

时间:2018-07-09 02:33:05

标签: python python-2.7 pyqt4 pickle importerror

我正在用python创建一个程序,允许您更改密码。这是让您更改密码的部分:

def done_clicked(self):
    password_filea = open("password.pkl", "r")
    password_check = pickle.load(password_filea)
    username_filea = open("username.pkl", "r")
    username_check = pickle.load(username_filea)


    if self.currpword.text() == password_check and self.reppword.text() == password_check and self.curruser.text() == username_check and self.repuser.text() == username_check:
        password_filea.close()
        username_filea.close()
        password_file = open("password.pkl", "wb")
        username_file = open("username.pkl", "wb")
        pickle.dump(self.newpword.text(), password_file)
        pickle.dump(self.newuser.text(), password_file)
        password_file.close()
        username_file.close()
        easygui.msgbox("Password Changed")

这是加载用户名和密码以供您登录的部分:

def sign_in_clicked(self):
    password_file = open("password.pkl", "rb")
    password = pickle.load(password_file)
    username_file = open("username.pkl", "rb")
    username = pickle.load(username_file)
    print username
    if self.pword.text() == password and self.username.text() == username:
        MainWindow.show()
        myWindow.hide()
    else:
        easygui.msgbox("Wrong Password!")
    password_file.close()
    username_file.close()

输入任何内容时,都会出现此错误:

    line 154, in sign_in_clicked
password = pickle.load(password_file)
ImportError: No module named sip

我该如何解决?请注意,这两个功能都在单独的类中。同样,当我从单独的文件中执行此操作时,它也可以完美工作,但是当它从同一文件中执行时(如示例中一样),则会出现错误。我正在导入Cpickle。提前致谢。

0 个答案:

没有答案