简体   繁体   English

无法在PyQt 5 on Windows导入QtMultimedia

[英]Can't import QtMultimedia in PyQt 5 on Windows

I'm trying to learn PyQt5 + qml, and everything I tried so far works fine, however I've ran into a snag when trying to import QtMultimedia into my qml file results in the following error:我正在尝试学习 PyQt5 + qml,到目前为止我尝试的一切都工作正常,但是当我尝试将 QtMultimedia 导入我的 qml 文件时遇到了问题导致以下错误:

plugin cannot be loaded for module "QtMultimedia": Cannot load library D:\py35venvQt\lib\site-packages\PyQt5\Qt\qml\QtMultimedia\declarative_multimedia.dll: The specified module could not be found.无法为模块“QtMultimedia”加载插件:无法加载库 D:\py35venvQt\lib\site-packages\PyQt5\Qt\qml\QtMultimedia\declarative_multimedia.dll:找不到指定的模块。

main.qml:主要.qml:

import QtQuick 2.8
import QtQuick.Window 2.2
import QtQuick.Layouts 1.3
import QtQuick.Controls 2.1
import QtMultimedia 5.6

Window {
  id: root
  visible: true
  title: 'my pyqt app'
  width: 1280
  height: 720

}

main.py主程序

if __name__ == '__main__':
    def handleStatusChange(status):
        if status == QQuickView.Error:
            errors = appLabel.errors()
            if errors:
                print (errors[0].description())



    myApp = QApplication(sys.argv)
    appLabel = QQuickView()
    appLabel.statusChanged.connect(handleStatusChange)
    model = models.ActorModel(DB_PATH)
    ctxt = appLabel.rootContext()
    ctxt.setContextProperty('myModel', model)
    appLabel.setSource(QUrl('./qml/main/main.qml'))

    try:
        sys.exit(myApp.exec_())
    except:
        print("Exiting")

Without the QtMultimedia import everything works fine, also I've tried all Possible version of QtMultimedia (5.0,5.1 etc).如果没有 QtMultimedia 导入,一切正常,我也尝试了所有可能的 QtMultimedia 版本(5.0、5.1 等)。 In addition the dll does exist in the correct path.此外 dll确实存在于正确的路径中。

When searching for a solution online I found some post saying that QtMultimedia is not supported in PyQt5, though I think those posts are too old.在网上搜索解决方案时,我发现一些帖子说 PyQt5 不支持 QtMultimedia,但我认为这些帖子太旧了。

I would appreciate it if someone would shed some light on this situation, Thank you.如果有人能阐明这种情况,我将不胜感激,谢谢。

Edit : Python Version 3.5.2 PyQt Version 5.8.编辑:Python 版本 3.5.2 PyQt 版本 5.8。 PyQt installation process: new virtualenv -> pip install pyqt5 PyQt安装过程:new virtualenv -> pip install pyqt5

Edit2 : Tried reinstalling to a completely new virtual environment using pip3 install pyqt5 still getting the same error. Edit2 :尝试使用pip3 install pyqt5重新安装到一个全新的虚拟环境,但仍然出现相同的错误。

Edit3 : According to http://www.dependencywalker.com the following dlls can not be found in the dir where declarative_multimedia.dll is: Edit3 :根据http://www.dependencywalker.com在 declarative_multimedia.dll 所在的目录中找不到以下 dll:

QT5MULTIMEDIA.DLL QT5QUICK.DLL QT5GUI.DLL QT5QML.DLL QT5CORE.DLL QT5MULTIMEDIAQUICK_P.DLL QT5MULTIMEDIA.DLL QT5QUICK.DLL QT5GUI.DLL QT5QML.DLL QT5CORE.DLL QT5MULTIMEDIAQUICK_P.8879876856

With the exception of QT5MULTIMEDIAQUICK_P.DLL they are all present in the \Lib\site-packages\PyQt5\Qt\bin directory除了 QT5MULTIMEDIAQUICK_P.DLL 它们都存在于\Lib\site-packages\PyQt5\Qt\bin目录中

QT5MULTIMEDIAQUICK_P.DLL is not present at all. QT5MULTIMEDIAQUICK_P.DLL 根本不存在。

I tried copying all the missing files into \Lib\site-packages\PyQt5\Qt\qml\QtMultimedia to see if it would make any difference.我尝试将所有丢失的文件复制到\Lib\site-packages\PyQt5\Qt\qml\QtMultimedia中,看看它是否会有任何不同。 It did not.它没。

I also tried to install PyQt 5 into my proper python 3.5 installation (without virtualenv) and running my code.我还尝试将 PyQt 5 安装到我正确的 python 3.5 安装(没有 virtualenv)并运行我的代码。 The result is the same.结果是一样的。

I had similar issue on Ubuntu and I solved my problem by adding environment variable LD_LIBRARY_PATH=/home/slav/Apps/Qt5.9.2/5.9.2/gcc_64/lib . 我在Ubuntu上有类似的问题,我通过添加环境变量LD_LIBRARY_PATH=/home/slav/Apps/Qt5.9.2/5.9.2/gcc_64/lib解决了我的问题。

" /home/slav/Apps/Qt5.9.2/5.9.2/gcc_64/lib " here I've install Qt with QtInstaller /home/slav/Apps/Qt5.9.2/5.9.2/gcc_64/lib ”在这里我用QtInstaller安装Qt

maybe You should use pyqt not pyside也许你应该使用 pyqt 而不是 pyside

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM