Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

PyQt5 - QtWebEngineWidgets, ImportError



  • Hallo everyone!

    I wanted to start a python-project by developing a web browser but I get stuck at the very start... quite annoying! I tried to check first at some similar problems in the web but without success.

    It seems that there is a problem with the location of the file libQt5Quick.so.5. I installed every package with pip3 (also uninstall and reinstall them).

    If someone could help me out of this I will be very happy!

    Thanks in advance,

    cards

    Here the details:

    Here the error:

    python3 -c "import PyQt5.QtWebEngineWidgets"
    

    Traceback (most recent call last):
    File "<string>", line 1, in <module>
    ImportError: libQt5Quick.so.5: cannot open shared object file: No such file or directory

    Here my settings:

    python3 --version
    

    Python 3.9.4

    pip3 list | grep PyQt
    

    PyQt5 5.15.4
    PyQt5-Qt5 5.15.2
    PyQt5-sip 12.9.0
    PyQtWebEngine 5.15.4
    PyQtWebEngine-Qt5 5.15.2

    Here the file location:

    find / -name "libQt5Quick.so.5" 2> /dev/null
    

    /usr/lib/python3.9/site-packages/PyQt5/Qt5/lib/libQt5Quick.so.5
    /usr/lib/python2.7/site-packages/PySide2/Qt/lib/libQt5Quick.so.5

    ls -l /usr/lib/python3.9/site-packages/PyQt5/Qt5/lib/libQt5Quick.so.5
    

    -rwxr-xr-x 1 root root 6.8M [...]



  • @cards said in PyQt5 - QtWebEngineWidgets, ImportError:

    ldd /usr/lib/python3.9/site-packages/PyQt5/Qt5/lib/libQt5Quick.so.5
    

    ?



  • @JonB thanks for the interest, here the object dependencies of libQt5Quick.so.5

    ldd /usr/lib/python3.9/site-packages/PyQt5/Qt5/lib/libQt5Quick.so.5
    
    linux-vdso.so.1 (0x00007ffe4cbd9000)
    libQt5QmlModels.so.5 => /usr/lib/python3.9/site-packages/PyQt5/Qt5/lib/libQt5QmlModels.so.5 (0x00007f2c660dc000)
    libQt5Qml.so.5 => /usr/lib/python3.9/site-packages/PyQt5/Qt5/lib/libQt5Qml.so.5 (0x00007f2c65a60000)
    libQt5Gui.so.5 => /usr/lib/python3.9/site-packages/PyQt5/Qt5/lib/libQt5Gui.so.5 (0x00007f2c6512f000)
    libQt5Network.so.5 => /usr/lib/python3.9/site-packages/PyQt5/Qt5/lib/libQt5Network.so.5 (0x00007f2c64d81000)
    libQt5Core.so.5 => /usr/lib/python3.9/site-packages/PyQt5/Qt5/lib/libQt5Core.so.5 (0x00007f2c6458b000)
    libpthread.so.0 => /usr/lib/libpthread.so.0 (0x00007f2c64547000)
    libGL.so.1 => /usr/lib/libGL.so.1 (0x00007f2c644bf000)
    libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00007f2c642e2000)
    libm.so.6 => /usr/lib/libm.so.6 (0x00007f2c6419d000)
    libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x00007f2c64183000)
    libc.so.6 => /usr/lib/libc.so.6 (0x00007f2c63fb6000)
    librt.so.1 => /usr/lib/librt.so.1 (0x00007f2c63fab000)
    libz.so.1 => /usr/lib/libz.so.1 (0x00007f2c63f8f000)
    libdl.so.2 => /usr/lib/libdl.so.2 (0x00007f2c63f88000)
    libgssapi_krb5.so.2 => /usr/lib/libgssapi_krb5.so.2 (0x00007f2c63f33000)
    libicui18n.so.56 => /usr/lib/python3.9/site-packages/PyQt5/Qt5/lib/libicui18n.so.56 (0x00007f2c63a9a000)
    libicuuc.so.56 => /usr/lib/python3.9/site-packages/PyQt5/Qt5/lib/libicuuc.so.56 (0x00007f2c636e2000)
    libicudata.so.56 => /usr/lib/python3.9/site-packages/PyQt5/Qt5/lib/libicudata.so.56 (0x00007f2c61cfd000)
    libgthread-2.0.so.0 => /usr/lib/libgthread-2.0.so.0 (0x00007f2c61cf8000)
    libglib-2.0.so.0 => /usr/lib/libglib-2.0.so.0 (0x00007f2c61bc3000)
    /usr/lib64/ld-linux-x86-64.so.2 (0x00007f2c66a94000)
    libGLdispatch.so.0 => /usr/lib/libGLdispatch.so.0 (0x00007f2c61b0b000)
    libGLX.so.0 => /usr/lib/libGLX.so.0 (0x00007f2c61ad8000)
    libkrb5.so.3 => /usr/lib/libkrb5.so.3 (0x00007f2c619f1000)
    libk5crypto.so.3 => /usr/lib/libk5crypto.so.3 (0x00007f2c619be000)
    libcom_err.so.2 => /usr/lib/libcom_err.so.2 (0x00007f2c619b8000)
    libkrb5support.so.0 => /usr/lib/libkrb5support.so.0 (0x00007f2c619a9000)
    libkeyutils.so.1 => /usr/lib/libkeyutils.so.1 (0x00007f2c619a2000)
    libresolv.so.2 => /usr/lib/libresolv.so.2 (0x00007f2c61988000)
    libpcre.so.1 => /usr/lib/libpcre.so.1 (0x00007f2c61916000)
    libX11.so.6 => /usr/lib/libX11.so.6 (0x00007f2c617d3000)
    libxcb.so.1 => /usr/lib/libxcb.so.1 (0x00007f2c617a9000)
    libXau.so.6 => /usr/lib/libXau.so.6 (0x00007f2c617a4000)
    libXdmcp.so.6 => /usr/lib/libXdmcp.so.6 (0x00007f2c6179c000)


  • @cards Looks OK, no "not found"s.



  • Goooood to know! Other modules such as QtCore, QtGui, QtWidgets, ... just work fine. Could it be something related to the path of the application executable? Or do you know others modules where the libQt5Quick.so.5 is required so that I can try to check if I get a similar error? Or...anything else?



  • @cards
    TBH I'm surprised QtWebEngineWidgets wants anything "QtQuick" at all. But I don't know that to be the case.



  • Thanks for your effort... If you will have any ideas be free to share them... the "easier" it looks, the more "difficult" it is, and this seems just to easy, so in this case a huge pain.



  • Some brain-damage updates:

    Step 0: not working sample code
    here my sample program (just copied-pasted from the web [I just needed smt working]) which gives rise to the famous

    ImportError: libQt5Quick.so.5: cannot open shared object file: No such file or directory

    #!/bin/python3
    # -*- coding: utf-8 -*-
    
    from PyQt5.QtCore import *
    from PyQt5.QtWidgets import *
    from PyQt5.QtGui import *
    from PyQt5.QtWebEngineWidgets import *
    
    
    import sys
    
    class MainWindow(QMainWindow):
    
        def __init__(self, *args, **kwargs):
            super(MainWindow,self).__init__(*args, **kwargs)
    
            self.browser = QWebEngineView()
            self.browser.setUrl(QUrl("https://doc.qt.io/qt-6/"))
    
            self.setCentralWidget(self.browser)
    
            self.show()
    
    app = QApplication(sys.argv)
    window = MainWindow()
    
    app.exec_()
    

    step 1: towards a debugging of the QtWebEngineWidgets-import
    I execute only this code

    #!/bin/python3
    # -*- coding: utf-8 -*-
    # list of PyQt modules
    qt_modules = ['QAxContainer','QtBluetooth','QtCore','QtDBus','QtDesigner','QtGui','QtHelp','QtLocation','QtMacExtras','QtMultimedia','QtMultimediaWidgets','QtNetwork','QtNfc','QtOpenGL','QtPositioning','QtPrintSupport','QtQml','QtQuick','QtQuickWidgets','QtSensors','QtSerialPort','QtSql','QtSvg','QtTest','QtWebChannel','QtWebEngineCore','QtWebEngineWidgets','QtWebKit','QtWebKitWidgets','QtWebSockets','QtWidgets','QtWinExtras','QtX11Extras','QtXml']
    # check if import modules is working
    for m in qt_modules:
       cmd = 'import PyQt5.{}'.format(m) # string command
       try:
           exec (cmd)
           exec ('del PyQt5.{}'.format(m)) # delete the import right after to avoid side effects
    	#print('[OK] import: ', cmd)
       except Exception as e:
           #print('[Er] import: ', cmd)
           print(type(e), e)
    

    output:
    [Er] import: import PyQt5.QAxContainer
    [Er] import: import PyQt5.QtMacExtras
    [Er] import: import PyQt5.QtWebKit
    [Er] import: import PyQt5.QtWebKitWidgets
    [Er] import: import PyQt5.QtWebWinExtra

    Comment: ... the QtWebEngineWidgets does not rise to problems!!

    step 2: I run 1st step 1 and then step 0

    #!/bin/python3
    # -*- coding: utf-8 -*-
    # list of PyQt modules
    [...]
    #blah blah from step 1
    qt_modules = [...] 
    from PyQt5.QtCore import *
    from PyQt5.QtWidgets import *
    from PyQt5.QtGui import *
    from PyQt5.QtWebEngineWidgets import *
    
    import sys
    
    class MainWindow(QMainWindow):
    #blah blah from step 0
    [...]
    

    Output
    Could not find QtWebEngineProcess
    Comment: I guess the by importing all PyQt5 modules the famous shared file libQt5Quick.so.5 is somehow it is fixed... but then another problem arise, no QtWebEngineProcess!
    What's going on? ...it seems that importing QtWebEngineWidgets module is more like a combinatorial problem!

    step 2*: summary - the import combinatorial-problem

    #!/bin/python3
    # -*- coding: utf-8 -*-
    
    qt_modules = ['QAxContainer','QtBluetooth','QtCore','QtDBus','QtDesigner','QtGui','QtHelp','QtLocation','QtMacExtras','QtMultimedia','QtMultimediaWidgets','QtNetwork','QtNfc','QtOpenGL','QtPositioning','QtPrintSupport','QtQml','QtQuick','QtQuickWidgets','QtSensors','QtSerialPort','QtSql','QtSvg','QtTest','QtWebChannel','QtWebEngineCore','QtWebEngineWidgets','QtWebKit','QtWebKitWidgets','QtWebSockets','QtWidgets','QtWinExtras','QtX11Extras','QtXml']
    
    for m in qt_modules:
        cmd = 'import PyQt5.{}'.format(m)
        try:
    	exec (cmd)
    	exec ('del PyQt5.{}'.format(m)) # delete the import right after to avoid side effects
        except Exception as e:
            pass
    		
    from PyQt5.QtWebEngineWidgets import *
    print('QWebEngineView' in dir())
    

    Output
    True
    Comment: much better, but what about step 2 and the Could not find QtWebEngineProcess? I still cannot run any program!

    TODO - Extra brain damage challange: I tried to detect the dependencies (don't how to call them) using a combinatorial approach to fix the module(s) which are responsible(s) to fix the libQt5Quick.so.5 problem BUT I don't know how to refresh to the original setting the python environment... (I am not sure the using the del command is enough)

    #!/bin/python3
    # -*- coding: utf-8 -*-
    from itertools import permutations
    
    qt_modules = ['QAxContainer','QtBluetooth','QtCore','QtDBus','QtDesigner','QtGui','QtHelp','QtLocation','QtMacExtras','QtMultimedia','QtMultimediaWidgets','QtNetwork','QtNfc','QtOpenGL','QtPositioning','QtPrintSupport','QtQml','QtQuick','QtQuickWidgets','QtSensors','QtSerialPort','QtSql','QtSvg','QtTest','QtWebChannel','QtWebEngineCore','QtWebEngineWidgets','QtWebKit','QtWebKitWidgets','QtWebSockets','QtWidgets','QtWinExtras','QtX11Extras','QtXml']
    
    for p1, p2 in permutations(qt_modules, 2): # to start just check for pair
       try:
    	cmd1 = 'import PyQt5.{}'.format(p1)
    	cmd2= 'import PyQt5.{}'.format(p2)
    	exec (cmd1) 	# import a pair of Qt5 modules
    	exec (cmd2)
    	from PyQt5.QtWebEngineWidgets import QWebEngineView # import test
    	print('Found lucky pair of modules: {}, {}'.format(p1, p2))
    
    	exec ('del PyQt5.{}'.format(p1)) # delete the import right after to avoid side effects
    	exec ('del PyQt5.{}'.format(p2)) # delete the import right after to avoid side effects
        except :
            pass
    

    Output:
    Found lucky pair od modules: QtBluetooth, QtWebChannel # it is the 56-combination!
    [...] then follows many many other but they could be biased since I don't how to refresh the python shell to the original setting

    Summa summarum

    • libQt5Quick.so.5 dependencies

    • how to start QtWebEngineProcess?

    Any kind of hits and/or solutions are welcome!!



  • @cards
    This all sounds unnecessarily complex. I installed Qt5 + PyQt5 + QtWebEngine up to and including Ubuntu 20.04, and never had your problems/issues.

    I can't be sure how I differ from you. One thing is I never build anything, I fetch everything from ubuntu apt-get. Something like:

    sudo apt-get install python3-pyqt5 python3-pyqt5.qtwebengine
    

    I never from ... import *, I just do from PyQt5.QtWebEngineWidgets import QWebEngineView.

    I note that I have /usr/lib/x86_64-linux-gnu/libQt5Quick.so.5 plus various files (meaning it got installed via apt-get).

    You never need to "how to start QtWebEngineProcess?". It will get started when your Python program accesses a WebEngine thing.


Log in to reply