ImportError: DLL load failed while importing QtWebKit: Le module spécifié est introuvable
ImportError: DLL load failed while importing QtWebKit: Le module spécifié est introuvable
代码:
我不知道为什么它在执行时没有 运行,知道我
下载了程序所需的所有库
from PyQt5.QtCore import QUrl
from PyQt5.QtWebKit import QWebSettings
from PyQt5.QtWebKitWidgets import QWebView, QWebInspector
from PyQt5.QtWidgets import QApplication, QSplitter, QVBoxLayout, QWidget
class Window(QWidget):
def __init__(self, parent=None):
QWidget.__init__(self, parent=parent)
self.view = QWebView(self)
self.view.settings().setAttribute(QWebSettings.DeveloperExtrasEnabled, True)
self.inspector = QWebInspector()
self.inspector.setPage(self.view.page())
self.inspector.show()
self.splitter = QSplitter(self)
self.splitter.addWidget(self.view)
self.splitter.addWidget(self.inspector)
layout = QVBoxLayout(self)
layout.addWidget(self.splitter)
if __name__ == '__main__':
import sys
app = QApplication(sys.argv)
window = Window()
window.view.load(QUrl('http://www.google.com'))
window.show()
sys.exit(app.exec_())
执行后:
Traceback (most recent call last):
File "c:\Users\pc\Desktop\tempCodeRunnerFile.py", line 2, in <module>
from PyQt5.QtWebKit import QWebSettings
ImportError: DLL load failed while importing QtWebKit: Le module spécifié est introuvable.
I don't know why it doesn't run at execution time, knowing that I
downloaded all the libraries needed by the program
图书馆 1 :
pip install PyQtWebEngine
图书馆 2 :
pip install PyQt5
这个问题有解决办法吗??
您示例的代码使用 QtWebKit,而不是 Qt WebEngine。如果你已经安装了 pyqtwebengine 然后使用下面的代码:
from PyQt5.QtCore import QUrl
from PyQt5.QtWidgets import QApplication, QSplitter, QVBoxLayout, QWidget
from PyQt5.QtWebEngineWidgets import QWebEngineView
class Window(QWidget):
def __init__(self, parent=None):
QWidget.__init__(self, parent=parent)
self.view = QWebEngineView()
self.inspector = QWebEngineView()
self.view.page().setDevToolsPage(self.inspector.page())
self.splitter = QSplitter(self)
self.splitter.addWidget(self.view)
self.splitter.addWidget(self.inspector)
layout = QVBoxLayout(self)
layout.addWidget(self.splitter)
if __name__ == "__main__":
import sys
app = QApplication(sys.argv)
window = Window()
window.view.load(QUrl("http://www.google.com"))
window.show()
sys.exit(app.exec_())
代码:
我不知道为什么它在执行时没有 运行,知道我 下载了程序所需的所有库
from PyQt5.QtCore import QUrl from PyQt5.QtWebKit import QWebSettings from PyQt5.QtWebKitWidgets import QWebView, QWebInspector from PyQt5.QtWidgets import QApplication, QSplitter, QVBoxLayout, QWidget class Window(QWidget): def __init__(self, parent=None): QWidget.__init__(self, parent=parent) self.view = QWebView(self) self.view.settings().setAttribute(QWebSettings.DeveloperExtrasEnabled, True) self.inspector = QWebInspector() self.inspector.setPage(self.view.page()) self.inspector.show() self.splitter = QSplitter(self) self.splitter.addWidget(self.view) self.splitter.addWidget(self.inspector) layout = QVBoxLayout(self) layout.addWidget(self.splitter) if __name__ == '__main__': import sys app = QApplication(sys.argv) window = Window() window.view.load(QUrl('http://www.google.com')) window.show() sys.exit(app.exec_())
执行后:
Traceback (most recent call last): File "c:\Users\pc\Desktop\tempCodeRunnerFile.py", line 2, in <module> from PyQt5.QtWebKit import QWebSettings ImportError: DLL load failed while importing QtWebKit: Le module spécifié est introuvable.
I don't know why it doesn't run at execution time, knowing that I downloaded all the libraries needed by the program
图书馆 1 :
pip install PyQtWebEngine
图书馆 2 :
pip install PyQt5
这个问题有解决办法吗??
您示例的代码使用 QtWebKit,而不是 Qt WebEngine。如果你已经安装了 pyqtwebengine 然后使用下面的代码:
from PyQt5.QtCore import QUrl
from PyQt5.QtWidgets import QApplication, QSplitter, QVBoxLayout, QWidget
from PyQt5.QtWebEngineWidgets import QWebEngineView
class Window(QWidget):
def __init__(self, parent=None):
QWidget.__init__(self, parent=parent)
self.view = QWebEngineView()
self.inspector = QWebEngineView()
self.view.page().setDevToolsPage(self.inspector.page())
self.splitter = QSplitter(self)
self.splitter.addWidget(self.view)
self.splitter.addWidget(self.inspector)
layout = QVBoxLayout(self)
layout.addWidget(self.splitter)
if __name__ == "__main__":
import sys
app = QApplication(sys.argv)
window = Window()
window.view.load(QUrl("http://www.google.com"))
window.show()
sys.exit(app.exec_())