I try to get the QWebEngineView() up and running under Windows 10 (Parallels Desktop aka. Virtual Machine). With MacOSX this is no issue at all, but while testing it on windows everything stalls. I narrowed down the issue to the QWebEngineView.
No matter what how I want to load a web-page / local html site into the QWebEngineView, nothing works.
For example I try the example of https://zetcode.com/pyqt/qwebengineview/ which launches, and for some seconds you see a white screen within the window and then everything is gone (see start of this clip https://imgur.com/a/PNTt2U2). There is no error message in the console, there is nothing.
Is there anything I'm missing to install?
python -m pip list
Package Version
----------------- --------
cachetools 4.2.2
future 0.18.2
pefile 2021.9.3
pip 21.2.4
py2exe 0.10.4.1
PyOpenGL 3.1.5
PyQt5 5.15.4
PyQt5-Qt5 5.15.2
PyQt5-sip 12.9.0
PyQtWebEngine 5.15.4
PyQtWebEngine-Qt5 5.15.2
PySide2 5.15.2
shiboken2 5.15.2
wheel 0.37.0
Probably related to this:
QWebEngineView not showing anything on Windows 10
PyQt5 QWebEngineView window won't show
I have just tried the below code on Windows 10 (not a Virtual Machine though) and it seems to work fine.
import sys
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtCore import *
from PyQt5.QtWebEngineWidgets import *
class Example(QWidget):
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
vbox = QVBoxLayout(self)
self.webEngineView = QWebEngineView()
self.webEngineView.setUrl(QUrl("https://doc.qt.io/qt-5.15/reference-overview.html"))
vbox.addWidget(self.webEngineView)
self.setLayout(vbox)
self.setGeometry(300, 300, 350, 250)
self.setWindowTitle('QWebEngineView')
if __name__ == '__main__':
app = QApplication(sys.argv)
ex = Example()
ex.show()
sys.exit(app.exec_())
Hope this helps, if not then you may be looking at a bigger issue (probably musicmante is on the right track)
Related
Windows 10 PyCharm Python 3.9.0
I installed PyQt6 and then pyqt6-tools in PyCharm throw the File->Settings.
Now when i run my program i am getting the following error in the terminal
from PyQt6.QtWidgets import QApplication, QWidget
PyQt6: DLL load failed while importing QtGui: The specified procedure could not be found.
My program code
import sys
from PyQt6.QtWidgets import QApplication, QWidget
app = QApplication(sys.args)
window = QWidget()
window.show()
app.exec()
How can i solve this problem?
The following command helped me solve this problem:
pip install --upgrade PyQt6
I want to execute a program which was written in python using PyQt5 and then migrated to PySide2 under MacOS Catalina.
With PyQt5 it was executing fine.
I have installed PySide2 like PyQt5:
python3 -m pip install PyQt5
python3 -m pip install PySide2
macOS was restarted afterwards.
Now, with PySide2 installed, I am getting an error in macOS when I am trying to load an Ui-file.
MRE which works under Linux, Windows and macOS Catalina:
#!/usr/bin/env python3
# Standard library imports
import sys
# Third party imports
from PySide2.QtCore import (QMetaObject,
Slot)
from PySide2.QtWidgets import (QApplication,
QWidget,
QPushButton,
QHBoxLayout,
QMessageBox)
def show_about():
msg = QMessageBox()
msg.setText("About this app.")
msg.setStandardButtons(QMessageBox.Ok)
msg.exec_()
class MainWindow(QWidget):
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
aboutButton = QPushButton("About")
aboutButton.setObjectName("aboutButton")
hbox = QHBoxLayout()
hbox.addStretch(1)
hbox.addWidget(aboutButton)
self.setLayout(hbox)
QMetaObject.connectSlotsByName(self)
self.setWindowTitle('Buttons')
#Slot()
def on_aboutButton_clicked(self):
show_about()
def main():
app = QApplication(sys.argv)
win = MainWindow()
win.show()
sys.exit(app.exec_())
if __name__ == '__main__':
main()
MRE which fails under macOS Catalina, but works in Linux and Windows:
#!/usr/bin/env python3
# Standard library imports
import sys
# Third party imports
from PySide2.QtWidgets import (QApplication,
QMainWindow)
from PySide2.QtUiTools import loadUiType
class MainWindow(QMainWindow, loadUiType("win_main.ui")[0]):
def __init__(self):
super().__init__()
self.setupUi(self)
def main():
app = QApplication(sys.argv)
win = MainWindow()
win.show()
sys.exit(app.exec_())
if __name__ == '__main__':
main()
Error:
Python 3.8.5 (/usr/local/bin/python3)
>>> %Run pyside2_win_main.py
Cannot run 'uic': "execvp: No such file or directory" - Exit status QProcess::NormalExit ( 255 )
Check if 'uic' is in PATH
Traceback (most recent call last):
File "/Users/dee/ownCloud3/rma2/pyside2_win_main.py", line 12, in <module>
class MainWindow(QMainWindow, loadUiType("win_main.ui")[0]):
TypeError: 'NoneType' object is not subscriptable
File structure for simplicity of test case:
/Users/dee/ownCloud3/rma2/pyside2_win_main.py
/Users/dee/ownCloud3/rma2/win_main.ui
PySide2 version 15.5.0, shiboken2==5.15.0.
macOS Calatina v10.15.06
Python 3.8.5 64bit (downloaded from here, no HomeBrew etc.
Don't use relative paths as they are susceptible to errors as it will depend on how the script is run, instead build an absolute path:
import os.path
CURRENT_DIR = os.path.dirname(os.path.realpath(__file__))
ui_file_path = os.path.join(CURRENT_DIR, "win_main.ui")
Ui_Class, _ = loadUiType(ui_file_path)
class MainWindow(QMainWindow, Ui_Class):
# ...
Also add at the top of your file, since it seems that when python was installed, the option to add the necessary paths to the environment variables was not marked:
import PySide2
import os.path
uic_dir = os.path.dirname(PySide2.__file__)
os.environ["PATH"] += os.pathsep + uic_dir
![My Code][1]
I installed all the libraries using pip and pip3.
I'm using python 3.8.3 and spyder 4.1.4
when ı writing codes IDE show me all libraries in QtWebEngine but trying to start my code IDE says
"module 'PyQt5' has no attribute 'QtWebEngineWidgets'"
and ı have all QtWebEngineWidgets files in computer.
import PyQt5 as py
import sys
app=py.QtWidgets.QApplication(sys.argv)
#app = Py.QApplication(sys.argv)
window = py.QtWidgets.QMainWindow()
window = py.QtWidgets.QWidget()
p=py.QtWebEngineWidgets.QWebEngineView(window)
b=py.QtCore.QUrl('https://stackoverflow.com')
p.load(b)
p.show()
window.setGeometry(0, 35, 400, 400)
window.setWindowTitle("Ground Control")
window.show()
app.exec_()
from PyQt5 import QtWidgets, QtWebEngineWidgets
pop this in and this should get you further
I am using PyCharm 2020.2 and I can't access PyQt5. From the Python interpreter it is showing PyQt5 ver 5.15.0. when I run this simple code
import sys
from PyQt5.QtWidgets import QApplication, QWidget
app = QApplication(sys.argv)
window = QWidget()
window.show()
app.exec_()
I am getting the following error: ModuleNotFoundError: No module named 'PyQt5'
I have no idea where to go next.
I installed PyQt5 with conda this way: conda install -c inso pyqt5=5.6. I have python 3.5. When I run a simple program that uses PyQt5, the program gets stuck on PyQt5 import and there is no error message. It gets stuck for about 5 seconds, then the program just terminates. See the example below that I found on google. The program gets stuck on the line from PyQt5.QtWidgets import QApplication, QWidget. I can see the packcage in C:\Users\user\Anaconda3\Lib\site-packages\PyQt5. What might be causing suck a behavior?
"""
ZetCode PyQt5 tutorial
In this example, we create a simple
window in PyQt5.
author: Jan Bodnar
website: zetcode.com
last edited: January 2015
"""
import sys
from PyQt5.QtWidgets import QApplication, QWidget
app = QApplication(sys.argv)
w = QWidget()
w.resize(250, 150)
w.move(300, 300)
w.setWindowTitle('Simple')
w.show()
sys.exit(app.exec_())
First comment here solved my problem. DLL load failed when importing PyQt5
I uninstalled pyqt5 and reinstalled wtih conda install --channel https://conda.anaconda.org/bpentz pyqt5