问题描述
我使用Qt Designer在Qt上创建了一个窗口,当我启动该应用程序时-我收到ImportError。感觉该库未安装在我的系统中。但是预览可以在Qt Designer中使用。
# -*- 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
错误日志:
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软件包是通过pip安装的。
解决方法
尝试卸载pyqt5重新安装,有用!
在pycharm终端中:
pip3 uninstall PyQt5
在 ubuntu 终端中:
sudo apt-get install python3-pyqt5