简体   繁体   English

如果我导入 QtWebEngineWidgets,PyQt5 会崩溃

[英]PyQt5 crashes if I import QtWebEngineWidgets

I created a new Anaconda environment with Python 3.6.我使用 Python 3.6 创建了一个新的 Anaconda 环境。 I installed PyQt5 with pip install PyQt5 .我用pip install PyQt5 I have this butt-simple program:我有这个简单的程序:

from PyQt5 import QtWidgets
#from PyQt5 import QtWebEngineWidgets

app = QtWidgets.QApplication([])

As written, it runs (and does nothing).正如所写,它运行(并且什么也不做)。 If I uncomment the QtWebEngineWidgets line, it crashes.如果我取消注释QtWebEngineWidgets行,它会崩溃。 If I leave that line uncommented, but comment out the final line, it no longer crashes.如果我不注释该行,但注释掉最后一行,则它不再崩溃。 In other words, it crashes when trying to create the application, but only if I previously tried to import QtWebEngineWidgets .换句话说,它在尝试创建应用程序时崩溃,但QtWebEngineWidgets是我之前尝试导入QtWebEngineWidgets Importing QtWebEngineWidgets itself doesn't cause a crash unless I try to create an application.除非我尝试创建应用程序,否则导入QtWebEngineWidgets本身不会导致崩溃。

I'm running this on Windows 7. The crash is a "hard" crash: it's not a Python exception, but a Windows popup saying "Python has stopped working".我在 Windows 7 上运行它。崩溃是一个“硬”崩溃:它不是 Python 异常,而是一个 Windows 弹出窗口,上面写着“Python 已停止工作”。 The info says that the crash is in "atio6axx.dll".信息说崩溃在“atio6axx.dll”中。 Googling around I see some hints that there could be some sort of conflict between Qt and my graphics driver, but I don't know how to debug it, let alone fix it.谷歌搜索我看到一些暗示 Qt 和我的图形驱动程序之间可能存在某种冲突,但我不知道如何调试它,更不用说修复它了。 (I have an embedded graphics controller that shows as ATI Radeon HD 4250.) (我有一个显示为 ATI Radeon HD 4250 的嵌入式图形控制器。)

conda list qt shows: conda list qt显示:

 PyQt5                     5.8.2                     <pip>

What can I do to be able to use QtWebEngine successfully?我该怎么做才能成功使用 QtWebEngine?

In my experience this issue has nothing to do with PyQt being installed using both pip and anaconda, although this would cause an problem too.根据我的经验,这个问题与使用 pip 和 anaconda 安装 PyQt 无关,尽管这也会导致问题。 If you only have pyqt installed on Anaconda the following code my cause a hard crash:如果您只在 Anaconda 上安装了 pyqt,以下代码会导致严重崩溃:

from qtpy import QtWidgets
from qtpy import QtWebEngineWidgets
app = QtWidgets.QApplication([])

We started experiencing this on a number of computers after an "upgrade" to windows 10, and noticing Spyder stopped working.在“升级”到 Windows 10 后,我们开始在多台计算机上遇到这种情况,并注意到 Spyder 停止工作。 It exited without an error message.它退出时没有错误消息。 The IT guys tracked it down to the graphics card. IT 人员将其追溯到显卡。

Solutions: downgrade pyqt to version 5.6: conda install pyqt=5.6解决方案:将pyqt降级到5.6版:conda install pyqt=5.6

I'm seeing this behavior on a windows 10 machine currently as well.我目前也在 Windows 10 机器上看到这种行为。
I use qtpy as well but have done this same example in just PyQt5.我也使用 qtpy,但只在 PyQt5 中做了同样的例子。

Downgraded to 5.6 changes other behavior li降级到 5.6 更改其他行为 li

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM