Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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:

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.

main.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). In addition the dll does exist in the correct path.

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.

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. PyQt installation process: new virtualenv -> pip install pyqt5

Edit2: Tried reinstalling to a completely new virtual environment using pip3 install pyqt5 still getting the same error.

Edit3: According to http://www.dependencywalker.com the following dlls can not be found in the dir where declarative_multimedia.dll is:

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

With the exception of QT5MULTIMEDIAQUICK_P.DLL they are all present in the \Lib\site-packages\PyQt5\Qt\bin directory

QT5MULTIMEDIAQUICK_P.DLL is not present at all.

I tried copying all the missing files into \Lib\site-packages\PyQt5\Qt\qml\QtMultimedia to see if it would make any difference. It did not.

I also tried to install PyQt 5 into my proper python 3.5 installation (without virtualenv) and running my code. The result is the same.

like image 339
Curtwagner1984 Avatar asked Nov 19 '22 02:11

Curtwagner1984


1 Answers

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.

"/home/slav/Apps/Qt5.9.2/5.9.2/gcc_64/lib" here I've install Qt with QtInstaller

like image 116
slavugan Avatar answered Mar 28 '23 09:03

slavugan