1062195630 发表于 2021-8-5 15:33:25

ModuleNotFoundError: No module named 'image_rc'

本帖最后由 1062195630 于 2021-8-5 16:08 编辑


###主程序
import sys
import sign_in_window
from PyQt5.QtWidgets import QApplication,QMainWindow

if __name__ == '__main__':
    app=QApplication(sys.argv)
    mainwindow=QMainWindow()
    ui=sign_in_window.Ui_sign_in_window()
    ui.setupUi(mainwindow)
    mainwindow.show()
    sys.exit(app.exec_())

!!!!!!!!!!!!为啥会报错啊ModuleNotFoundError: No module named 'image_rc'

######sign_in_window程序
# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'sign_in_window.ui'
#
# Created by: PyQt5 UI code generator 5.15.4
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again.Do not edit this file unless you know what you are doing.


from PyQt5 import QtCore, QtGui, QtWidgets


class Ui_sign_in_window(object):
    def setupUi(self, sign_in_window):
      sign_in_window.setObjectName("sign_in_window")
      sign_in_window.resize(624, 265)
      self.horizontalLayout_2 = QtWidgets.QHBoxLayout(sign_in_window)
      self.horizontalLayout_2.setObjectName("horizontalLayout_2")
      self.graphicsView_2 = QtWidgets.QGraphicsView(sign_in_window)
      self.graphicsView_2.setStyleSheet("border-image: url(:/photo/fasheaixin.gif);")
      self.graphicsView_2.setObjectName("graphicsView_2")
      self.horizontalLayout_2.addWidget(self.graphicsView_2)
      self.line = QtWidgets.QFrame(sign_in_window)
      self.line.setFrameShape(QtWidgets.QFrame.VLine)
      self.line.setFrameShadow(QtWidgets.QFrame.Sunken)
      self.line.setObjectName("line")
      self.horizontalLayout_2.addWidget(self.line)
      self.verticalLayout_3 = QtWidgets.QVBoxLayout()
      self.verticalLayout_3.setObjectName("verticalLayout_3")
      spacerItem = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
      self.verticalLayout_3.addItem(spacerItem)
      self.label_3 = QtWidgets.QLabel(sign_in_window)
      self.label_3.setObjectName("label_3")
      self.verticalLayout_3.addWidget(self.label_3)
      self.horizontalLayout = QtWidgets.QHBoxLayout()
      self.horizontalLayout.setContentsMargins(-1, -1, 0, 10)
      self.horizontalLayout.setObjectName("horizontalLayout")
      self.verticalLayout_2 = QtWidgets.QVBoxLayout()
      self.verticalLayout_2.setObjectName("verticalLayout_2")
      self.label = QtWidgets.QLabel(sign_in_window)
      self.label.setObjectName("label")
      self.verticalLayout_2.addWidget(self.label)
      self.label_2 = QtWidgets.QLabel(sign_in_window)
      self.label_2.setObjectName("label_2")
      self.verticalLayout_2.addWidget(self.label_2)
      self.horizontalLayout.addLayout(self.verticalLayout_2)
      self.verticalLayout = QtWidgets.QVBoxLayout()
      self.verticalLayout.setObjectName("verticalLayout")
      self.account = QtWidgets.QLineEdit(sign_in_window)
      self.account.setObjectName("account")
      self.verticalLayout.addWidget(self.account)
      self.secret = QtWidgets.QLineEdit(sign_in_window)
      self.secret.setObjectName("secret")
      self.verticalLayout.addWidget(self.secret)
      self.horizontalLayout.addLayout(self.verticalLayout)
      self.horizontalLayout.setStretch(0, 1)
      self.horizontalLayout.setStretch(1, 3)
      self.verticalLayout_3.addLayout(self.horizontalLayout)
      self.horizontalLayout_3 = QtWidgets.QHBoxLayout()
      self.horizontalLayout_3.setContentsMargins(-1, 12, 0, 0)
      self.horizontalLayout_3.setSpacing(11)
      self.horizontalLayout_3.setObjectName("horizontalLayout_3")
      spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
      self.horizontalLayout_3.addItem(spacerItem1)
      self.sign_in_button = QtWidgets.QPushButton(sign_in_window)
      self.sign_in_button.setObjectName("sign_in_button")
      self.horizontalLayout_3.addWidget(self.sign_in_button)
      spacerItem2 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
      self.horizontalLayout_3.addItem(spacerItem2)
      self.verticalLayout_3.addLayout(self.horizontalLayout_3)
      spacerItem3 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
      self.verticalLayout_3.addItem(spacerItem3)
      self.verticalLayout_3.setStretch(1, 2)
      self.verticalLayout_3.setStretch(2, 1)
      self.verticalLayout_3.setStretch(3, 1)
      self.verticalLayout_3.setStretch(4, 2)
      self.horizontalLayout_2.addLayout(self.verticalLayout_3)

      self.retranslateUi(sign_in_window)
      QtCore.QMetaObject.connectSlotsByName(sign_in_window)

    def retranslateUi(self, sign_in_window):
      _translate = QtCore.QCoreApplication.translate
      sign_in_window.setWindowTitle(_translate("sign_in_window", "mylover"))
      self.label_3.setText(_translate("sign_in_window", "亲爱滴臭宝!请输入账号密码呦....."))
      self.label.setText(_translate("sign_in_window", "账号"))
      self.label_2.setText(_translate("sign_in_window", "密码"))
      self.sign_in_button.setText(_translate("sign_in_window", "登录"))
import image_rc

大马强 发表于 2021-8-5 20:42:09

为啥你的 import image_rc 写在这么下面
image_rc 是你自己写的文件吗,是的话会不会是不在同一文件夹下
或者参考https://blog.csdn.net/qq_42455308/article/details/106865415?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522162816712216780269860392%2522%252C%2522scm%2522%253A%252220140713.130102334..%2522%257D&request_id=162816712216780269860392&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~all~sobaiduend~default-1-106865415.first_rank_v2_pc_rank_v29&utm_term=ModuleNotFoundError%3A+No+module+named+%27image_rc%27&spm=1018.2226.3001.4187
页: [1]
查看完整版本: ModuleNotFoundError: No module named 'image_rc'