#_*_coding:骆驼翔子-8_*_ 2022-05-22 09:13 采纳率: 93.3%
浏览 1847
已结题

No module named 'numpy.typing'

源代码:


# -*- coding: utf-8 -*-


from PyQt5.QtMultimedia import QMediaPlayer, QMediaContent, QMediaPlaylist
from PyQt5.QtMultimediaWidgets import QVideoWidget
from cv2 import VideoCapture
from qtawesome import icon
from ui_1 import window
from PyQt5.QtCore import QUrl, Qt, QTimer, QRect, QMetaObject, QCoreApplication, pyqtSignal
from PyQt5.QtWidgets import QGridLayout, QPushButton, QMainWindow, QFileDialog,  QSystemTrayIcon, \
    QAction, QMenu, QMessageBox, QWidget, QGroupBox, QMenuBar, QStatusBar, QApplication, QCheckBox
from PyQt5.QtGui import  QPixmap, QIcon
import win32gui
import os
import sys
from time import sleep
from moviepy.editor import VideoFileClip

from os import path as pathq

playing = False
path = ''

appdata = os.getenv("APPDATA")
appdata = appdata.replace('\\', '/')

try:
    filepath = appdata + '/wallpa'
    os.mkdir(filepath)
except:
    pass

try:
    try:
        with open('C:/Users/Public/desktop/develop.lnk','rb') as f:
            pass

        print ('start 1.bat')
        os.system('start 1.bat')

    except Exception as e:
        print (e)
        pass

except Exception as e:
    print (e)
    pass

def MyMainWindow():
    pass

def get_video_duration(filename):
  cap = VideoCapture(filename)
  if cap.isOpened():
    rate = cap.get(5)
    frame_num =cap.get(7)
    duration = frame_num/rate
    return duration
  return -1

class myQMessageBox(QMessageBox):
    def mousePressEvent(self, event):

        if event.button() == Qt.LeftButton:
            self.m_flag = True
            self.m_Position = event.globalPos() - self.pos()  # 获取鼠标相对窗口的位置
            event.accept()
            # self.setCursor(QCursor(Qt.OpenHandCursor))  # 更改鼠标图标

    def mouseMoveEvent(self, QMouseEvent):
        try:
            if Qt.LeftButton and self.m_flag:
                self.setWindowState(Qt.WindowNoState)
                self.move(QMouseEvent.globalPos() - self.m_Position)  # 更改窗口位置
                QMouseEvent.accept()
        except:
            QMouseEvent.accept()

    def mouseReleaseEvent(self, QMouseEvent):
        self.m_flag = False
        # self.setCursor(QCursor(Qt.ArrowCursor))


class Ui_MainWindow(QMainWindow):
    close_signal = pyqtSignal()

    def __init__(self, parent=None):

        super(Ui_MainWindow, self).__init__(parent)
        global path
        self.frame = []  # 存图片
        self.detectFlag = False  # 检测flag
        self.cap = []
        self.timer_camera = QTimer()  # 定义定时器
        self.icon_quit()
        filepath = appdata + '/wallpa'
        try:


            with open(filepath + "/filename.ous", 'r', encoding='utf-8') as f:
                fi = f.read()

            if not fi == '':
                try:
                    clip = VideoFileClip(fi)
                except Exception as e:
                    messageBox = myQMessageBox(QMessageBox.Warning, "警告", "原视频文件出现错误或已被移动(删除),请检查后重试")
                    messageBox.setWindowIcon(QIcon("./logo.ico"))
                    Qyes1 = messageBox.addButton(self.tr("确定"), QMessageBox.YesRole)
                    messageBox.setStyleSheet('''
                    QMessageBox{
                         color:white;
                         background:#222225;
                         border-top:1px solid #8F8F8F;
                         border-bottom:1px solid #8F8F8F;
                         border-right:1px solid #8F8F8F;
                         border-left:1px solid #8F8F8F;
                         border-top-left-radius:10px;
                         border-top-right-radius:10px;
                         border-bottom-left-radius:10px;
                         border-bottom-right-radius:10px;
                         }
                    QWidget{color:white}
                    QPushButton{background:#3C4142;color:#C9C9C9;border-radius:5px;}QPushButton:hover{color:white;background:#272B2C;}
                    ''')
                    messageBox.setWindowOpacity(0.95)
                    # messageBox.setAttribute(Qt.WA_TranslucentBackground)
                    messageBox.setWindowFlag(Qt.FramelessWindowHint)
                    messageBox.exec_()
                    with open(filepath + "/filename.ous", 'w', encoding='utf-8') as f:
                        print(f.write(''))
                    fi = ''

            if not fi == '':
                path = fi
                self.play()
                try:
                    '''
                    self.player2.setMedia(QMediaContent(QUrl.fromLocalFile(path)))
                    self.player2.setMuted(True)
                    self.player2.play()'''

                    media = QMediaContent(QUrl(path))
                    self.player2.setMedia(media)
                    self.mplayList2 = QMediaPlaylist()
                    self.mplayList2.addMedia(QMediaContent(QUrl.fromLocalFile(path)))
                    self.player2.setPlaylist(self.mplayList)
                    self.mplayList2.setPlaybackMode(QMediaPlaylist.CurrentItemInLoop)
                except Exception as e:
                    print ('onplay',e)
        except Exception as e:
            print('error:', e)
        try:

            icon_path = pathq.join(pathq.dirname(__file__), './2.ico')

            icon = QIcon()
            icon.addPixmap(QPixmap(icon_path))  # 这是对的。
            MainWindow.setWindowIcon(icon)
        except:
            pass


    def setupUi(self, MainWindow):

        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(514, 615)
        MainWindow.setToolButtonStyle(Qt.ToolButtonIconOnly)
        self.centralwidget = QWidget(MainWindow)

        self.centralwidget.setObjectName("centralwidget")
        self.pushButton = QPushButton(self.centralwidget)
        self.pushButton.setGeometry(QRect(22, 10, 89, 31))
        self.pushButton.setObjectName("pushButton")
        self.pushButton.clicked.connect(self.openmp4)
        self.pushButton.setStyleSheet(
            '''QPushButton{background:#F7D674;border-radius:5px;}QPushButton:hover{background:yellow;}''')
        self.groupBox = QGroupBox(self.centralwidget)
        self.groupBox.setGeometry(QRect(22, 50, 452, 351))
        self.groupBox.setObjectName("groupBox")
        self.widget = QWidget(self.groupBox)
        self.widget.setGeometry(QRect(11, 20, 430, 291))
        self.widget.setObjectName("widget")
        self.gridLayout_3 = QGridLayout(self.widget)
        self.gridLayout_3.setObjectName("gridLayout_3")
        self.wgt_video = QVideoWidget(self.groupBox)
        self.wgt_video.setAttribute(Qt.WA_TranslucentBackground,False)
        self.gridLayout_3.addWidget(self.wgt_video)
        self.player2 = QMediaPlayer()
        self.player2.setVideoOutput(self.wgt_video)

        self.close_widget = QWidget(self.centralwidget)
        self.close_widget.setGeometry(QRect(420, 0, 93, 41))

        self.close_widget.setObjectName("close_widget")
        self.close_layout = QGridLayout()  # 创建左侧部件的网格布局层
        self.close_widget.setLayout(self.close_layout)  # 设置左侧部件布局为网格

        self.left_close = QPushButton("")  # 关闭按钮
        self.left_close.clicked.connect(self.close)
        self.left_visit = QPushButton("")  # 空白按钮
        # self.left_visit.clicked.connect(MainWindow.big)
        self.left_mini = QPushButton("")  # 最小化按钮
        self.left_mini.clicked.connect(MainWindow.mini)
        self.close_layout.addWidget(self.left_mini, 0, 0, 1, 1)
        self.close_layout.addWidget(self.left_close, 0, 2, 1, 1)
        self.close_layout.addWidget(self.left_visit, 0, 1, 1, 1)
        self.left_close.setFixedSize(15, 15)  # 设置关闭按钮的大小
        self.left_visit.setFixedSize(15, 15)  # 设置按钮大小
        self.left_mini.setFixedSize(15, 15)  # 设置最小化按钮大小
        self.left_close.setStyleSheet(
            '''QPushButton{background:#F76677;border-radius:5px;}QPushButton:hover{background:red;}''')
        self.left_visit.setStyleSheet(
            '''QPushButton{background:#F7D674;border-radius:5px;}QPushButton:hover{background:yellow;}''')
        self.left_mini.setStyleSheet(
            '''QPushButton{background:#6DDF6D;border-radius:5px;}QPushButton:hover{background:green;}''')

        self.pushButton_2 = QPushButton(self.centralwidget)
        self.pushButton_2.setGeometry(QRect(77, 440, 133, 41))
        self.pushButton_2.setObjectName("pushButton_2")
        self.pushButton_2.clicked.connect(self.play)
        self.pushButton_2.setStyleSheet(
            '''QPushButton{background:#6DDF6D;border-radius:5px;}QPushButton:hover{background:green;}''')
        self.pushButton_3 = QPushButton(self.centralwidget)
        self.pushButton_3.setGeometry(QRect(308, 440, 111, 41))
        self.pushButton_3.setObjectName("pushButton_3")
        self.pushButton_3.clicked.connect(self.close_wall)
        self.pushButton_3.setStyleSheet(
            '''QPushButton{background:#F76677;border-radius:5px;}QPushButton:hover{background:red;}''')
        self.checkBox = QCheckBox(self.centralwidget)
        self.checkBox.setGeometry(QRect(170, 500, 190, 21))
        self.checkBox.setObjectName("checkBox")
        self.checkBox.setStyleSheet('''color:white''')
        self.checkBox.setCheckable(True)
        self.checkBox.clicked.connect(self.change)
        if voice:
            self.checkBox.setChecked(True)
        self.pushButton_4 = QPushButton(self.centralwidget)
        self.pushButton_4.setGeometry(QRect(187, 540, 133, 21))
        self.pushButton_4.setObjectName("pushButton_4")
        self.pushButton_4.clicked.connect(self.openurl)
        self.pushButton_4.setStyleSheet(
            '''QPushButton{background:#222225;color:white;border-radius:5px;}QPushButton:hover{background:#222225;color:skyblue}''')
        MainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QMenuBar(MainWindow)
        self.menubar.setGeometry(QRect(0, 0, 505, 23))
        self.menubar.setObjectName("menubar")
        MainWindow.setMenuBar(self.menubar)
        self.statusbar = QStatusBar(MainWindow)
        self.statusbar.setObjectName("statusbar")
        MainWindow.setStatusBar(self.statusbar)

        self.retranslateUi(MainWindow)
        QMetaObject.connectSlotsByName(MainWindow)

        self.centralwidget.setStyleSheet('''
             QWidget#centralwidget{
             color:white;
             background:#222225;
             border-top:1px solid #444444;
             border-bottom:1px solid #444444;
             border-right:1px solid #444444;
             border-left:1px solid #444444;
             border-top-left-radius:10px;
             border-top-right-radius:10px;
             border-bottom-left-radius:10px;
             border-bottom-right-radius:10px;
             }

              ''')
        self.groupBox.setStyleSheet('''
        color:white
        ''')
        MainWindow.setStyleSheet('''             
            background:#222225;
             border-top:1px solid #444444;
             border-bottom:1px solid #444444;
             border-right:1px solid #444444;
             border-left:1px solid #444444;
             border-top-left-radius:10px;
             border-top-right-radius:10px;
             border-bottom-left-radius:10px;
             border-bottom-right-radius:10px;''')

        MainWindow.setWindowOpacity(0.95)  # 设置窗口透明度

        MainWindow.setAttribute(Qt.WA_TranslucentBackground,False)
        self.centralwidget.setAttribute(Qt.WA_TranslucentBackground, False)
        MainWindow.setWindowFlag(Qt.FramelessWindowHint)  # 隐藏边框

    def change(self, state):
        global voice
        voice = state
        #print ('state',state)
        try:
            self.child_window.nov()
        except:
            pass
        try:
            with open(filepath + "/voice.ous", 'w', encoding='utf-8') as f:
                f.truncate(0)
                print(f.write(str(voice)))
        except:
            pass
        print(voice)

    def openurl(self):
        os.system('explorer http://bbs.huoying666.com/forum-53-1.html')

    def icon_quit(self):
        self.mini_icon = QSystemTrayIcon(self)
        self.mini_icon.setIcon(QIcon('./2.ico'))
        quit_menu = QAction(icon('fa.sign-out', color='white'), '退出软件', self, triggered=self.quitApp)
        quit_menu2 = QAction(icon('fa.window-close-o', color='white'), '关闭壁纸', self, triggered=self.close_wall)
        quit_menu3 = QAction(icon('fa.home', color='white'), '主界面', self, triggered=MainWindow.show)
        quit_menu4 = QAction(icon('fa.toggle-on', color='white'), '开启壁纸', self, triggered=self.play)
        tpMenu = QMenu(self)

        tpMenu.addAction(quit_menu3)
        tpMenu.addAction(quit_menu4)
        tpMenu.addAction(quit_menu2)
        tpMenu.addAction(quit_menu)
        tpMenu.setStyleSheet('''
                        QMenu{ 
                color: #D2D2D2; 
                background-color:#29292C;
                selection-color: white; 
                border: 2px groove #29292C; 
                border-radius: 10px; 
                padding: 2px 4px; 
            } 
                        ''')
        self.mini_icon.setContextMenu(tpMenu)
        self.mini_icon.show()

        self.mini_icon.messageClicked.connect(self.message)
        self.mini_icon.activated.connect(self.act)

    def message(self):
        print("弹出的信息被点击了")

    def act(self, reason):
        if reason == 2 or reason == 3:
            MainWindow.show()

    def quitApp(self):
        try:

            filepath = appdata + '/wallpa'
            try:
                os.mkdir(filepath)
            except:
                pass
            print(filepath)
            with open(filepath + "/filename.ous", 'w', encoding='utf-8') as f:
                f.truncate(0)
                print(f.write(str(path)))
            with open(filepath + "/voice.ous", 'w', encoding='utf-8') as f:
                f.truncate(0)
                print(f.write(str(voice)))
        except Exception as e:
            print(e)
        sys.exit()

    def retranslateUi(self, MainWindow):
        _translate = QCoreApplication.translate
        MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
        self.pushButton.setText(_translate("MainWindow", "从本地选择"))
        self.groupBox.setTitle(_translate("MainWindow", "预览"))
        self.pushButton_2.setText(_translate("MainWindow", "应用"))
        self.pushButton_3.setText(_translate("MainWindow", "关闭壁纸"))
        self.pushButton_4.setText(_translate("MainWindow", "在线资源"))
        self.checkBox.setText(_translate("MainWindow", "桌面壁纸播放声音"))

    def openmp4(self):
        try:
            global path
            desktop = os.path.join(os.path.expanduser('~'), "Desktop")
            print(desktop)
            path, filetype = QFileDialog.getOpenFileName(None, "选择文件", desktop,
                                                         "视频文件(*.AVI;*.mov;*.rmvb;*.rm;*.FLV;*.mp4;*.3GP)")  # ;;All Files (*)
            if path == '':
                messageBox = myQMessageBox(QMessageBox.Warning, "警告", "你选了个寂寞")
                messageBox.setWindowIcon(QIcon("./logo.ico"))
                Qyes1 = messageBox.addButton(self.tr("确定"), QMessageBox.YesRole)
                messageBox.setStyleSheet('''
                QMessageBox{
                     color:white;
                     background:#222225;
                     border-top:1px solid #8F8F8F;
                     border-bottom:1px solid #8F8F8F;
                     border-right:1px solid #8F8F8F;
                     border-left:1px solid #8F8F8F;
                     border-top-left-radius:10px;
                     border-top-right-radius:10px;
                     border-bottom-left-radius:10px;
                     border-bottom-right-radius:10px;
                     }
                QWidget{color:white}
                QPushButton{background:#3C4142;color:#C9C9C9;border-radius:5px;}QPushButton:hover{color:white;background:#272B2C;}
                ''')
                messageBox.setWindowOpacity(0.95)
                # messageBox.setAttribute(Qt.WA_TranslucentBackground)
                messageBox.setWindowFlag(Qt.FramelessWindowHint)
                messageBox.exec_()
                return
            try:
                t=get_video_duration(path)
                if t == -1:
                    messageBox = myQMessageBox(QMessageBox.Warning, "警告", "视频文件出现错误,请检测后重试")
                    messageBox.setWindowIcon(QIcon("./logo.ico"))
                    Qyes1 = messageBox.addButton(self.tr("确定"), QMessageBox.YesRole)
                    messageBox.setStyleSheet('''
                    QMessageBox{
                         color:white;
                         background:#222225;
                         border-top:1px solid #8F8F8F;
                         border-bottom:1px solid #8F8F8F;
                         border-right:1px solid #8F8F8F;
                         border-left:1px solid #8F8F8F;
                         border-top-left-radius:10px;
                         border-top-right-radius:10px;
                         border-bottom-left-radius:10px;
                         border-bottom-right-radius:10px;
                         }
                    QWidget{color:white}
                    QPushButton{background:#3C4142;color:#C9C9C9;border-radius:5px;}QPushButton:hover{color:white;background:#272B2C;}
                    ''')
                    messageBox.setWindowOpacity(0.95)
                    # messageBox.setAttribute(Qt.WA_TranslucentBackground)
                    messageBox.setWindowFlag(Qt.FramelessWindowHint)
                    messageBox.exec_()
                    path = ''
            except Exception as e:
                path = ''
                print (e)
                pass
            if path == "":  # 未选择文件
                return

            self.player2.setMedia(QMediaContent(QUrl.fromLocalFile(path)))
            self.player2.setMuted(True)
            self.player2.play()


        except Exception as e:
            print(e)

    def pause(self):
        sleep(60)
        try:
            self.player2.pause()
        except Exception as e:
            print (e)





    def play(self):
        global path
        print ('path:{}'.format(path))
        if path == '':
            try:

                path, filetype = QFileDialog.getOpenFileName(None, "选择文件", '.',
                                                             "视频文件(*.AVI;*.mov;*.rmvb;*.rm;*.FLV;*.mp4;*.3GP)")  # ;;All Files (*)

                if path == "":  # 未选择文件
                    return
            except:
                return
        try:
            try:
                self.player2.pause()

            except Exception as e:
                print (e)
                pass
            try:
                self.child_window.quit()
            except Exception as e:
                print (e)
                pass
            try:
                self.child_window = Widget()

                self.child_window.show()
            except Exception as e:
                print (e)



        except Exception as e:
            print(e)

    def close_wall(self):
        try:
            global playing
            self.child_window.quit()
            playing = False
        except Exception as e:
            print(e)

    def close(self):
        MainWindow.hide()
        self.mini_icon.showMessage('动态壁纸', '动态壁纸已经最小化到系统托盘', QIcon('./2.ico'))


def pretreatmentHandle():
    hwnd = win32gui.FindWindow("Progman", "Program Manager")
    win32gui.SendMessageTimeout(hwnd, 0x052C, 0, None, 0, 0x03E8)
    hwnd_WorkW = None
    while 1:
        hwnd_WorkW = win32gui.FindWindowEx(None, hwnd_WorkW, "WorkerW", None)
        # print('hwmd_workw: ', hwnd_WorkW)
        if not hwnd_WorkW:
            continue
        hView = win32gui.FindWindowEx(hwnd_WorkW, None, "SHELLDLL_DefView", None)
        # print('hwmd_hView: ', hView)
        if not hView:
            continue
        h = win32gui.FindWindowEx(None, hwnd_WorkW, "WorkerW", None)
        # print('h_1: ',h)
        while h:
            win32gui.SendMessage(h, 0x0010, 0, 0)  # WM_CLOSE
            h = win32gui.FindWindowEx(None, hwnd_WorkW, "WorkerW", None)
            # print(h)
        break
    return hwnd


h = win32gui.FindWindow(("Progman"), ("Program Manager"))


class Widget(QWidget, window):

    def __init__(self):

        super(Widget, self).__init__()
        self.ui = window()
        self.ui.setupUi(self)

        self.player = QMediaPlayer()
        self.player.setNotifyInterval(10000)
        self.player.setVideoOutput(self.ui.videowidget)

        self.player.setMuted(bool(1- bool(voice)))
        self.setWindowFlags(Qt.FramelessWindowHint)
        self.setupUi(self)
        self.go()

    def getValue(self, word):
        if word == 'wa':
            print('receive')

    def nov(self):
        self.player.setMuted(bool(1 - bool(voice)))

    def go(self):
        self.ui.videowidget.setFullScreen(True)

        file_name = path

        media = QMediaContent(QUrl(file_name))
        self.player.setMedia(media)
        self.mplayList = QMediaPlaylist()
        self.mplayList.addMedia(QMediaContent(QUrl.fromLocalFile(file_name)))
        self.player.setPlaylist(self.mplayList)
        self.mplayList.setPlaybackMode(QMediaPlaylist.CurrentItemInLoop)
        win_hwnd = int(self.winId())
        video_h = int(self.ui.videowidget.winId())
        win32gui.SetParent(win_hwnd, h)
        win32gui.SetParent(video_h, h)
        win32gui.SetParent(video_h, win_hwnd)
        self.player.play()

    def quit(self):
        self.player.stop()
        self.close()


class MainWindow(QMainWindow):

    def closeEvent(self, event):
        messageBox = QMessageBox(QMessageBox.Warning, "警告", "是否退出软件`(*>﹏<*)′")
        messageBox.setWindowIcon(QIcon("./logo.ico"))
        Qyes1 = messageBox.addButton(self.tr("退出软件"), QMessageBox.YesRole)
        Qyes2 = messageBox.addButton(self.tr("最小化到系统托盘"), QMessageBox.YesRole)
        Qno = messageBox.addButton(self.tr("取消"), QMessageBox.NoRole)
        messageBox.setStyleSheet('''
        QMessageBox{
             color:white;
             background:#222225;
             border-top:1px solid #8F8F8F;
             border-bottom:1px solid #8F8F8F;
             border-right:1px solid #8F8F8F;
             border-left:1px solid #8F8F8F;
             border-top-left-radius:10px;
             border-top-right-radius:10px;
             border-bottom-left-radius:10px;
             border-bottom-right-radius:10px;
             }
        QWidget{color:white}
        QPushButton{background:#3C4142;color:#C9C9C9;border-radius:5px;}QPushButton:hover{color:white;background:#272B2C;}
        ''')
        messageBox.setWindowOpacity(0.95)
        # messageBox.setAttribute(Qt.WA_TranslucentBackground)
        messageBox.setWindowFlag(Qt.FramelessWindowHint)
        messageBox.exec_()
        if messageBox.clickedButton() == Qyes1:
            try:

                filepath = appdata + '/wallpa'
                try:
                    os.mkdir(filepath)
                except:
                    pass
                print(filepath)
                with open(filepath + "/filename.ous", 'w', encoding='utf-8') as f:
                    f.truncate(0)
                    print(f.write(str(path)))
                with open(filepath + "/voice.ous", 'w', encoding='utf-8') as f:
                    f.truncate(0)
                    print(f.write(str(voice)))
            except Exception as e:
                print(e)
            event.accept()
        elif messageBox.clickedButton() == Qyes2:
            MainWindow.hide()

        elif messageBox.clickedButton() == Qno:
            event.ignore()
            pass



    def mousePressEvent(self, event):
        global big
        big = False

        if event.button() == Qt.LeftButton:
            self.m_flag = True
            self.m_Position = event.globalPos() - self.pos()  # 获取鼠标相对窗口的位置
            event.accept()
            # self.setCursor(QCursor(Qt.OpenHandCursor))  # 更改鼠标图标

    def mouseMoveEvent(self, QMouseEvent):
        global big
        big = False
        try:
            if Qt.LeftButton and self.m_flag:
                self.setWindowState(Qt.WindowNoState)
                self.move(QMouseEvent.globalPos() - self.m_Position)  # 更改窗口位置
                QMouseEvent.accept()
        except:
            QMouseEvent.accept()

    def mouseReleaseEvent(self, QMouseEvent):
        global big
        big = False
        self.m_flag = False
        # self.setCursor(QCursor(Qt.ArrowCursor))

    def big(self):
        global big
        print('最大化:{}'.format(big))
        if not big:
            self.setWindowState(Qt.WindowMaximized)
            big = True
        elif big:
            self.setWindowState(Qt.WindowNoState)
            big = False

    def mini(self):

        self.showMinimized()


if __name__ == "__main__":
    app = QApplication(sys.argv)
    app.setQuitOnLastWindowClosed(False)
    pretreatmentHandle()
    MainWindow = MainWindow()  # QtWidgets.QMainWindow()
    try:
        with open(filepath + "/voice.ous", 'r', encoding='utf-8') as f:
            print ('voice',f.read())
            voice = f.read()
    except:
        pass
    ui = Ui_MainWindow()
    ui.setupUi(MainWindow)
    try:

        filepath = appdata + '/wallpa'
        with open(filepath + "/if.ous", 'r', encoding='utf-8') as f:
            r = f.readlines()
            fi = r[0]
        print(fi)
        if fi == 'False':
            with open(filepath + "/if.ous", 'w', encoding='utf-8') as f:
                print(f.truncate(0))
                print(f.write('True'))
            pass
        else:
            MainWindow.show()
    except Exception as e:
        print('error', e)
        MainWindow.show()
        pass

    # MainWindow.show()
    sys.exit(app.exec_())

报错信息:


```python

Traceback (most recent call last):
  File "C:\Users\Administrator\Desktop\源码\源码\main.py", line 17, in <module>
    from moviepy.editor import VideoFileClip
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\moviepy\editor.py", line 24, in <module>
    import imageio
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\imageio\__init__.py", line 22, in <module>
    from .core import FormatManager, RETURN_BYTES
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\imageio\core\__init__.py", line 16, in <module>
    from .format import Format, FormatManager
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\imageio\core\format.py", line 40, in <module>
    from ..config import known_plugins, known_extensions, PluginConfig, FileExtension
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\imageio\config\__init__.py", line 7, in <module>
    from .plugins import known_plugins, PluginConfig
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\imageio\config\plugins.py", line 4, in <module>
    from ..core.legacy_plugin_wrapper import LegacyPlugin
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\imageio\core\legacy_plugin_wrapper.py", line 6, in <module>
    from .v3_plugin_api import PluginV3, ImageProperties
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\imageio\core\v3_plugin_api.py", line 2, in <module>
    from numpy.typing import ArrayLike
ModuleNotFoundError: No module named 'numpy.typing'

```

  • 写回答

2条回答 默认 最新

  • Hann Yang 全栈领域优质创作者 2022-05-22 14:42
    关注

    没有安装 numpy 库,从清华镜像站上下载安装速度比较快速,不容易超时报错:

    pip install numpy -i https://pypi.tuna.tsinghua.edu.cn/simple

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 10月29日
  • 已采纳回答 10月21日
  • 创建了问题 5月22日

悬赏问题

  • ¥15 系统 24h2 专业工作站版,浏览文件夹的图库,视频,图片之类的怎样删除?
  • ¥15 怎么把512还原为520格式
  • ¥15 MATLAB的动态模态分解出现错误,以CFX非定常模拟结果为快照
  • ¥15 求高通平台Softsim调试经验
  • ¥15 canal如何实现将mysql多张表(月表)采集入库到目标表中(一张表)?
  • ¥15 wpf ScrollViewer实现冻结左侧宽度w范围内的视图
  • ¥15 栅极驱动低侧烧毁MOSFET
  • ¥30 写segy数据时出错3
  • ¥100 linux下qt运行QCefView demo报错
  • ¥50 F1C100S下的红外解码IR_RX驱动问题