7

I created a Window on Qt with Qt Designer and when I launch that app - I get ImportError. It feels like that library doesn't installed in my system. But the preview works in Qt Designer.

Full code of design file:

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

# Form implementation generated from reading ui file 'map.ui'
#
# Created by: PyQt5 UI code generator 5.15.0
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again.  Do not edit this file unless you know what you are doing.


from PyQt5 import QtCore, QtGui, QtWidgets


class Ui_Form(object):
    def setupUi(self, Form):
        Form.setObjectName("Form")
        Form.resize(576, 616)
        self.horizontalLayout = QtWidgets.QHBoxLayout(Form)
        self.horizontalLayout.setObjectName("horizontalLayout")
        self.webView = QtWebEngineWidgets.QWebView(Form)
        self.webView.setUrl(QtCore.QUrl("https://www.openstreetmap.org/"))
        self.webView.setRenderHints(QtGui.QPainter.Antialiasing|QtGui.QPainter.SmoothPixmapTransform|QtGui.QPainter.TextAntialiasing)
        self.webView.setObjectName("webView")
        self.horizontalLayout.addWidget(self.webView)

        self.retranslateUi(Form)
        QtCore.QMetaObject.connectSlotsByName(Form)

    def retranslateUi(self, Form):
        _translate = QtCore.QCoreApplication.translate
        Form.setWindowTitle(_translate("Form", "VasMaps"))
        
from PyQt5 import QtWebEngineWidgets

Error log:

Traceback (most recent call last):
  File "Qt/map.py", line 31, in <module>
    from PyQt5 import QtWebEngineWidgets
ImportError: /lib/x86_64-linux-gnu/libQt5Core.so.5: version `Qt_5.15' not found (required by /usr/local/lib/python3.8/dist-packages/PyQt5/QtWebEngineWidgets.abi3.so)

PyQtWebEngine package is installed via pip.

Okno
  • 71
  • 1
  • 1
  • 4
  • 1
    Does this help? https://stackoverflow.com/questions/39129615/pyqt5-not-finding-installed-qt5-library – jairoar Sep 15 '20 at 15:21
  • 1) what is your OS? 2) how have you installed pyqt5 and pyqtwebengine? – eyllanesc Sep 15 '20 at 18:30
  • do not combine the installation of pip with apt-get, I recommend you uninstall pyqtwebengine and use `sudo apt-get install python3-pyqt5.qtwebengine` – eyllanesc Sep 15 '20 at 18:33

3 Answers3

12

I try to uninstall pyqt5 and install it again,it is useful!

in pycharm terminal:

pip3 uninstall PyQt5

in ubuntu terminal:

sudo apt-get install python3-pyqt5
烟花易冷
  • 121
  • 1
  • 3
  • This also seems to fail when I'm using a python environment – Justin Furuness Apr 26 '21 at 00:34
  • 1
    I had exactly the same error message in QGIS. I had to uninstall PyQt5 with pip, and couldn't install python3-pyqt5, because this package was already present. But the uninstall solved the problem for me. Thanks!!! – V Damoy Jun 25 '21 at 12:29
  • This can help if pyqt was at some point installed via pip and might be conflicting with the version installed (or not) by the OS package manager. In my case, I had to uninstall the version from pip, and then *reinstall* the version through the package manager, because it was also marked as installed. I think the two versions were conflicting in some way or another (which was to be expected... once you realize that it was in fact installed twice.) – Zak Mar 17 '23 at 17:02
1

Try this:

  1. find libQtCore version
$ ls /lib/x86_64-linux-gnu/libQt5Core.so*
/lib/x86_64-linux-gnu/libQt5Core.so
/lib/x86_64-linux-gnu/libQt5Core.so.5
/lib/x86_64-linux-gnu/libQt5Core.so.5.12
/lib/x86_64-linux-gnu/libQt5Core.so.5.12.8
  1. uninstall currnet pyqt5
$ pip3 uninstall pyqt5
  1. install correct version
$ pip3 install pyqt5==5.12
altex
  • 11
  • 1
0

None of the above solutions helped me. What did help was trashing the anaconda environment with default python 3.11, creating a new environment with python=3.8, and installing pyqt5 with pip.

Aleksejs Fomins
  • 688
  • 1
  • 8
  • 20