Operating System is Windows 10. Whenever I try to display any form of .html file, whether it is local or on the internet, I either get a UI from PyQt6 that is blank, or error:
I have successfully installed required dependencies, pip install PyQt6 PyQt6-WebEngine.
Full output is
[Running] python -u "c:\Users\PC\OneDrive\Desktop\main.py"
[Done] exited with code=3221226505 in 0.46 seconds
This is my code
from PyQt6.QtWidgets import QApplication, QWidget, QVBoxLayout
from PyQt6.QtWebEngineWidgets import QWebEngineView
from PyQt6.QtCore import QUrl
app = QApplication([])
window = QWidget()
layout = QVBoxLayout()
view = QWebEngineView()
layout.addWidget(view)
view.setUrl(QUrl("/"))
window.setLayout(layout)
window.show()
app.exec()
Operating System is Windows 10. Whenever I try to display any form of .html file, whether it is local or on the internet, I either get a UI from PyQt6 that is blank, or error:
I have successfully installed required dependencies, pip install PyQt6 PyQt6-WebEngine.
Full output is
[Running] python -u "c:\Users\PC\OneDrive\Desktop\main.py"
[Done] exited with code=3221226505 in 0.46 seconds
This is my code
from PyQt6.QtWidgets import QApplication, QWidget, QVBoxLayout
from PyQt6.QtWebEngineWidgets import QWebEngineView
from PyQt6.QtCore import QUrl
app = QApplication([])
window = QWidget()
layout = QVBoxLayout()
view = QWebEngineView()
layout.addWidget(view)
view.setUrl(QUrl("https://www.google/"))
window.setLayout(layout)
window.show()
app.exec()
Running this I get:
Argument list is empty, the program name is not passed to QCoreApplication. base::CommandLine cannot be properly initialized.
So your program DOES print an error. But the way you run python (from inside another process?) seems to suppress / ignore the stderr
.
To fix it, pass sys.argv
(or some non-empty dummy list) to your QApplication()
:
import sys
# ...
app = QApplication(sys.argv)
From the docs for QApplication:
Warning: [...] In addition, argc must be greater than zero and argv must contain at least one valid character string.
Which translated to Python means the list passed to the constructor needs to be non-empty.
QT_VERSION_STR
. – musicamante Commented Mar 5 at 23:40setUrl
? Maybe problem is in different place. You could useprint()
to see which lines were executed before error. – furas Commented Mar 6 at 0:46