import sys
from PyQt5.QtWidgets import QApplication, QMainWindow, QWebEngineView
app = QApplication(sys.argv)
window = QMainWindow()
view = QWebEngineView()
view.load(QUrl("http://www.google.com"))
window.setCentralWidget(view)
window.show()
sys.exit(app.exec_())
这正是我在代码中遇到的错误:
Traceback (most recent call last):
File "C:\Users\eymen\Desktop\qtweb.py", line 2, in <module>
from PyQt5.QtWidgets import QApplication, QMainWindow, QWebEngineView
ImportError: cannot import name 'QWebEngineView' from 'PyQt5.QtWidgets' (C:\Users\eymen\AppData\Local\Programs\Python\Python311\Lib\site-packages\PyQt5\QtWidgets.pyd)
但我的pyqt5版本是最新的,我没有看到任何错误。我以为它与Python版本有关,但我不知道。Python版本:3.11.1备选库不能满足我的要求。
import sys
from PyQt5.QtWidgets import QApplication, QMainWindow, QWebEngineView
app = QApplication(sys.argv)
window = QMainWindow()
view = QWebEngineView()
view.load(QUrl("http://www.google.com"))
window.setCentralWidget(view)
window.show()
sys.exit(app.exec_())
我尝试了这段代码,但当它应该google.com在python窗口中显示www.example.com时,它给出了错误,并说QWebEngineView库不受支持
1条答案
按热度按时间smdncfj31#
你需要使用
代码: