我正在创建一个PyQt5 + qml应用程序。 Windows 10,PyQt5 5.13.2,Python 3.6。一切正常,直到我尝试导入QtMultimedia,这会导致错误消息:

QQmlApplicationEngine failed to load component
file:///C:/Users/user/PycharmProjects/Project/project/pyqt-gui/pyqt-gui/main.qml:9
plugin cannot be loaded for module "QtMultimedia": Cannot load library C:\Users\user\PycharmProjects\Project\venv\lib\site-packages\PyQt5\Qt\qml\QtMultimedia\declarative_multimedia.dll: The specified module could not be found.

这似乎在不同的虚拟环境以及PyQt和QtMultimedia版本中仍然存在。我也已确认环境中存在.dll文件。

main.qml:

import QtQuick 2.12
import QtQuick.Window 2.12
import QtQuick.Layouts 1.3
import QtQuick.Controls 2.13
import QtQuick.Shapes 1.11
import QtQuick.Dialogs 1.1
import QtQuick.Controls.Styles 1.4
import QtCharts 2.3
import QtMultimedia 5.10

ApplicationWindow {
    id: appWindow
    visible: true
    width: 1920
    height: 1080
    color: "#313131"
    title: qsTr("Project PyQt")
}

main.py:

import sys

from PyQt5.QtQml import QQmlApplicationEngine
from PyQt5.QtWidgets import QApplication
from PyQt5.QtCore import QUrl

from interface import Interface

if __name__ == '__main__':
    app = QApplication(sys.argv)

    appEngine = QQmlApplicationEngine()

    context = appEngine.rootContext()

    appEngine.load(QUrl('pyqt-gui/main.qml'))

    win = appEngine.rootObjects()[0]

    # Register Python classes with qml
    interface = Interface(app, context, win)

    context.setContextProperty('iface', interface)

    win.show()
    try:
        apcode = app.exec_()
    except:
        print('there was an issue')
    finally:
        sys.exit(apcode)

任何关于我要去哪里错误的建议都非常感谢,我非常困惑!

pip install pyqt5
os.environ["QT_DEBUG_PLUGINS"] = "1"
QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/shires/PycharmProjects/DeepLabCut/venv/lib/site-packages/PyQt5/Qt/plugins/platforms" ...
QFactoryLoader::QFactoryLoader() looking at "C:/Users/shires/PycharmProjects/DeepLabCut/venv/lib/site-packages/PyQt5/Qt/plugins/platforms/qminimal.dll"
Found metadata in lib C:/Users/shires/PycharmProjects/DeepLabCut/venv/lib/site-packages/PyQt5/Qt/plugins/platforms/qminimal.dll, metadata=
{
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
        "Keys": [
            "minimal"
        ]
    },
    "archreq": 0,
    "className": "QMinimalIntegrationPlugin",
    "debug": false,
    "version": 331008
}


Got keys from plugin meta data ("minimal")
QFactoryLoader::QFactoryLoader() looking at "C:/Users/shires/PycharmProjects/DeepLabCut/venv/lib/site-packages/PyQt5/Qt/plugins/platforms/qoffscreen.dll"
Found metadata in lib C:/Users/shires/PycharmProjects/DeepLabCut/venv/lib/site-packages/PyQt5/Qt/plugins/platforms/qoffscreen.dll, metadata=
{
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
        "Keys": [
            "offscreen"
        ]
    },
    "archreq": 0,
    "className": "QOffscreenIntegrationPlugin",
    "debug": false,
    "version": 331008
}


Got keys from plugin meta data ("offscreen")
QFactoryLoader::QFactoryLoader() looking at "C:/Users/shires/PycharmProjects/DeepLabCut/venv/lib/site-packages/PyQt5/Qt/plugins/platforms/qwebgl.dll"
Found metadata in lib C:/Users/shires/PycharmProjects/DeepLabCut/venv/lib/site-packages/PyQt5/Qt/plugins/platforms/qwebgl.dll, metadata=
{
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
        "Keys": [
            "webgl"
        ]
    },
    "archreq": 0,
    "className": "QWebGLIntegrationPlugin",
    "debug": false,
    "version": 331008
}


Got keys from plugin meta data ("webgl")
QFactoryLoader::QFactoryLoader() looking at "C:/Users/shires/PycharmProjects/DeepLabCut/venv/lib/site-packages/PyQt5/Qt/plugins/platforms/qwindows.dll"
Found metadata in lib C:/Users/shires/PycharmProjects/DeepLabCut/venv/lib/site-packages/PyQt5/Qt/plugins/platforms/qwindows.dll, metadata=
{
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
        "Keys": [
            "windows"
        ]
    },
    "archreq": 0,
    "className": "QWindowsIntegrationPlugin",
    "debug": false,
    "version": 331008
}


Got keys from plugin meta data ("windows")
QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/shires/PycharmProjects/DeepLabCut/venv/Scripts/platforms" ...
loaded library "C:/Users/shires/PycharmProjects/DeepLabCut/venv/lib/site-packages/PyQt5/Qt/plugins/platforms/qwindows.dll"
QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/shires/PycharmProjects/DeepLabCut/venv/lib/site-packages/PyQt5/Qt/plugins/platformthemes" ...
QFactoryLoader::QFactoryLoader() looking at "C:/Users/shires/PycharmProjects/DeepLabCut/venv/lib/site-packages/PyQt5/Qt/plugins/platformthemes/qxdgdesktopportal.dll"
Found metadata in lib C:/Users/shires/PycharmProjects/DeepLabCut/venv/lib/site-packages/PyQt5/Qt/plugins/platformthemes/qxdgdesktopportal.dll, metadata=
{
    "IID": "org.qt-project.Qt.QPA.QPlatformThemeFactoryInterface.5.1",
    "MetaData": {
        "Keys": [
            "xdgdesktopportal",
            "flatpak",
            "snap"
        ]
    },
    "archreq": 0,
    "className": "QXdgDesktopPortalThemePlugin",
    "debug": false,
    "version": 331008
}


Got keys from plugin meta data ("xdgdesktopportal", "flatpak", "snap")
QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/shires/PycharmProjects/DeepLabCut/venv/Scripts/platformthemes" ...
QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/shires/PycharmProjects/DeepLabCut/venv/lib/site-packages/PyQt5/Qt/plugins/styles" ...
QFactoryLoader::QFactoryLoader() looking at "C:/Users/shires/PycharmProjects/DeepLabCut/venv/lib/site-packages/PyQt5/Qt/plugins/styles/qwindowsvistastyle.dll"
Found metadata in lib C:/Users/shires/PycharmProjects/DeepLabCut/venv/lib/site-packages/PyQt5/Qt/plugins/styles/qwindowsvistastyle.dll, metadata=
{
    "IID": "org.qt-project.Qt.QStyleFactoryInterface",
    "MetaData": {
        "Keys": [
            "windowsvista"
        ]
    },
    "archreq": 0,
    "className": "QWindowsVistaStylePlugin",
    "debug": false,
    "version": 331008
}


Got keys from plugin meta data ("windowsvista")
QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/shires/PycharmProjects/DeepLabCut/venv/Scripts/styles" ...
loaded library "C:/Users/shires/PycharmProjects/DeepLabCut/venv/lib/site-packages/PyQt5/Qt/plugins/styles/qwindowsvistastyle.dll"
Found metadata in lib C:/Users/shires/PycharmProjects/DeepLabCut/venv/lib/site-packages/PyQt5/Qt/qml/QtQuick.2/qtquick2plugin.dll, metadata=
{
    "IID": "org.qt-project.Qt.QQmlExtensionInterface/1.0",
    "archreq": 0,
    "className": "QtQuick2Plugin",
    "debug": false,
    "uri": [
        "QtQuick.2"
    ],
    "version": 331008
}


loaded library "C:/Users/shires/PycharmProjects/DeepLabCut/venv/lib/site-packages/PyQt5/Qt/qml/QtQuick.2/qtquick2plugin.dll"
Found metadata in lib C:/Users/shires/PycharmProjects/DeepLabCut/venv/lib/site-packages/PyQt5/Qt/qml/QtQuick/Window.2/windowplugin.dll, metadata=
{
    "IID": "org.qt-project.Qt.QQmlExtensionInterface/1.0",
    "archreq": 0,
    "className": "QtQuick2WindowPlugin",
    "debug": false,
    "uri": [
        "QtQuick.Window.2"
    ],
    "version": 331008
}


loaded library "C:/Users/shires/PycharmProjects/DeepLabCut/venv/lib/site-packages/PyQt5/Qt/qml/QtQuick/Window.2/windowplugin.dll"
Found metadata in lib C:/Users/shires/PycharmProjects/DeepLabCut/venv/lib/site-packages/PyQt5/Qt/qml/QtQuick/Layouts/qquicklayoutsplugin.dll, metadata=
{
    "IID": "org.qt-project.Qt.QQmlExtensionInterface/1.0",
    "archreq": 0,
    "className": "QtQuickLayoutsPlugin",
    "debug": false,
    "uri": [
        "QtQuick.Layouts"
    ],
    "version": 331008
}


loaded library "C:/Users/shires/PycharmProjects/DeepLabCut/venv/lib/site-packages/PyQt5/Qt/qml/QtQuick/Layouts/qquicklayoutsplugin.dll"
Found metadata in lib C:/Users/shires/PycharmProjects/DeepLabCut/venv/lib/site-packages/PyQt5/Qt/qml/QtQuick/Controls.2/qtquickcontrols2plugin.dll, metadata=
{
    "IID": "org.qt-project.Qt.QQmlExtensionInterface/1.0",
    "archreq": 0,
    "className": "QtQuickControls2Plugin",
    "debug": false,
    "uri": [
        "QtQuick.Controls.2"
    ],
    "version": 331008
}


loaded library "C:/Users/shires/PycharmProjects/DeepLabCut/venv/lib/site-packages/PyQt5/Qt/qml/QtQuick/Controls.2/qtquickcontrols2plugin.dll"
Found metadata in lib C:/Users/shires/PycharmProjects/DeepLabCut/venv/lib/site-packages/PyQt5/Qt/qml/QtQuick/Shapes/qmlshapesplugin.dll, metadata=
{
    "IID": "org.qt-project.Qt.QQmlExtensionInterface/1.0",
    "archreq": 0,
    "className": "QmlShapesPlugin",
    "debug": false,
    "uri": [
        "QtQuick.Shapes"
    ],
    "version": 331008
}


loaded library "C:/Users/shires/PycharmProjects/DeepLabCut/venv/lib/site-packages/PyQt5/Qt/qml/QtQuick/Shapes/qmlshapesplugin.dll"
Found metadata in lib C:/Users/shires/PycharmProjects/DeepLabCut/venv/lib/site-packages/PyQt5/Qt/qml/QtQuick/Dialogs/dialogplugin.dll, metadata=
{
    "IID": "org.qt-project.Qt.QQmlExtensionInterface/1.0",
    "archreq": 0,
    "className": "QtQuick2DialogsPlugin",
    "debug": false,
    "uri": [
        "QtQuick.Dialogs"
    ],
    "version": 331008
}


loaded library "C:/Users/shires/PycharmProjects/DeepLabCut/venv/lib/site-packages/PyQt5/Qt/qml/QtQuick/Dialogs/dialogplugin.dll"
Found metadata in lib C:/Users/shires/PycharmProjects/DeepLabCut/venv/lib/site-packages/PyQt5/Qt/qml/QtCharts/qtchartsqml2.dll, metadata=
{
    "IID": "org.qt-project.Qt.QQmlExtensionInterface/1.0",
    "archreq": 0,
    "className": "QtChartsQml2Plugin",
    "debug": false,
    "uri": [
        "QtCharts"
    ],
    "version": 331008
}


loaded library "C:/Users/shires/PycharmProjects/DeepLabCut/venv/lib/site-packages/PyQt5/Qt/qml/QtCharts/qtchartsqml2.dll"
Found metadata in lib C:/Users/shires/PycharmProjects/DeepLabCut/venv/lib/site-packages/PyQt5/Qt/qml/QtMultimedia/declarative_multimedia.dll, metadata=
{
    "IID": "org.qt-project.Qt.QQmlExtensionInterface/1.0",
    "archreq": 0,
    "className": "QMultimediaDeclarativeModule",
    "debug": false,
    "uri": [
        "QtMultimedia"
    ],
    "version": 331008
}


Cannot load library C:\Users\shires\PycharmProjects\DeepLabCut\venv\lib\site-packages\PyQt5\Qt\qml\QtMultimedia\declarative_multimedia.dll: The specified module could not be found.
QLibraryPrivate::loadPlugin failed on "C:/Users/shires/PycharmProjects/DeepLabCut/venv/lib/site-packages/PyQt5/Qt/qml/QtMultimedia/declarative_multimedia.dll" : "Cannot load library C:\\Users\\shires\\PycharmProjects\\DeepLabCut\\venv\\lib\\site-packages\\PyQt5\\Qt\\qml\\QtMultimedia\\declarative_multimedia.dll: The specified module could not be found."
QQmlApplicationEngine failed to load component
file:///C:/Users/shires/PycharmProjects/DeepLabCut/deeplabcut/pyqt-gui/pyqt-gui/main.qml:9 plugin cannot be loaded for module "QtMultimedia": Cannot load library C:\Users\shires\PycharmProjects\DeepLabCut\venv\lib\site-packages\PyQt5\Qt\qml\QtMultimedia\declarative_multimedia.dll: The specified module could not be found.

Traceback (most recent call last):
  File "C:/Users/shires/PycharmProjects/DeepLabCut/deeplabcut/pyqt-gui/main.py", line 20, in <module>
    win = appEngine.rootObjects()[0]
IndexError: list index out of range
QLibraryPrivate::unload succeeded on "C:/Users/shires/PycharmProjects/DeepLabCut/venv/lib/site-packages/PyQt5/Qt/plugins/styles/qwindowsvistastyle.dll" 
QLibraryPrivate::unload succeeded on "C:/Users/shires/PycharmProjects/DeepLabCut/venv/lib/site-packages/PyQt5/Qt/plugins/platforms/qwindows.dll" 
On QtCore unload, "C:/Users/shires/PycharmProjects/DeepLabCut/venv/lib/site-packages/PyQt5/Qt/qml/QtCharts/qtchartsqml2.dll" was leaked, with 2 users
On QtCore unload, "C:/Users/shires/PycharmProjects/DeepLabCut/venv/lib/site-packages/PyQt5/Qt/qml/QtQuick.2/qtquick2plugin.dll" was leaked, with 2 users
On QtCore unload, "C:/Users/shires/PycharmProjects/DeepLabCut/venv/lib/site-packages/PyQt5/Qt/qml/QtQuick/Controls.2/qtquickcontrols2plugin.dll" was leaked, with 2 users
On QtCore unload, "C:/Users/shires/PycharmProjects/DeepLabCut/venv/lib/site-packages/PyQt5/Qt/qml/QtQuick/Dialogs/dialogplugin.dll" was leaked, with 2 users
On QtCore unload, "C:/Users/shires/PycharmProjects/DeepLabCut/venv/lib/site-packages/PyQt5/Qt/qml/QtQuick/Layouts/qquicklayoutsplugin.dll" was leaked, with 2 users
On QtCore unload, "C:/Users/shires/PycharmProjects/DeepLabCut/venv/lib/site-packages/PyQt5/Qt/qml/QtQuick/Shapes/qmlshapesplugin.dll" was leaked, with 2 users
On QtCore unload, "C:/Users/shires/PycharmProjects/DeepLabCut/venv/lib/site-packages/PyQt5/Qt/qml/QtQuick/Window.2/windowplugin.dll" was leaked, with 2 users

Process finished with exit code 1

编辑2:在“丢失的” .dll上使用依赖项遍历器:

Dependency walker