Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 简单的PyQt5 QML应用程序导致分段错误_Python_Qt_Qml_Pyqt5 - Fatal编程技术网

Python 简单的PyQt5 QML应用程序导致分段错误

Python 简单的PyQt5 QML应用程序导致分段错误,python,qt,qml,pyqt5,Python,Qt,Qml,Pyqt5,在试图让a运行时,我发现我遇到了一个分段错误。我验证了它似乎只处理显示QML,因为它运行良好。我尝试了以下最小测试: #!/usr/bin/python3 import sys from PyQt5.QtCore import QUrl from PyQt5.QtWidgets import QGuiApplication from PyQt5.QtQml import QQmlApplicationEngine # Main Function if __name__ == '__main__

在试图让a运行时,我发现我遇到了一个分段错误。我验证了它似乎只处理显示QML,因为它运行良好。我尝试了以下最小测试:

#!/usr/bin/python3
import sys
from PyQt5.QtCore import QUrl
from PyQt5.QtWidgets import QGuiApplication
from PyQt5.QtQml import QQmlApplicationEngine

# Main Function
if __name__ == '__main__':
    app = QGuiApplication(sys.argv)
    engine = QQmlApplicationEngine("simple.qml")
    engine.quit.connect(app.quit)
    sys.exit(app.exec_())
simple.qml:

import QtQuick 2.5
import QtQuick.Controls 1.4

ApplicationWindow {
    width: 300
    height: 200
    title: "Simple"
    visible: true
}
当我运行这个应用程序时,一个窗口会在关闭前出现一秒钟,如更详细的示例中所示,我在控制台中收到
分段错误
(仅此而已)

从GDB运行显示
QSGRenderThread
正在接收SIGSEGV:

(gdb) run snowman_qt.py 
Starting program: /usr/bin/python3 snowman_qt.py
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7fffe912b700 (LWP 17200)]
[New Thread 0x7fffe3dbb700 (LWP 17201)]
[New Thread 0x7fffe1442700 (LWP 17202)]
[New Thread 0x7fffdbfff700 (LWP 17203)]

Thread 5 "QSGRenderThread" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffdbfff700 (LWP 17203)]
__strstr_sse2 (haystack_start=0x0, needle_start=0x7fffe28c9dd0 "nouveau") at ../string/strstr.c:63
63  ../string/strstr.c: No such file or directory.
回溯如下:

#0  __strstr_sse2 (haystack_start=0x0, needle_start=0x7fffe28c9dd0 "nouveau") at ../string/strstr.c:63
#1  0x00007fffe27233ea in QSGRenderContext::initialize(QOpenGLContext*) ()
   from /usr/local/lib/python3.5/dist-packages/PyQt5/Qt/qml/QtQuick.2/../../lib/libQt5Quick.so.5
#2  0x00007fffe273e979 in ?? ()
   from /usr/local/lib/python3.5/dist-packages/PyQt5/Qt/qml/QtQuick.2/../../lib/libQt5Quick.so.5
#3  0x00007ffff56835f9 in ?? () from /usr/local/lib/python3.5/dist-packages/PyQt5/Qt/lib/libQt5Core.so.5
#4  0x00007ffff7bc16fa in start_thread (arg=0x7fffdbfff700) at pthread_create.c:333
#5  0x00007ffff78f7b5d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109
如果我运行QML文件,就不会出现分段错误,应用程序也会正常工作。请注意,我使用的PyQT没有PyOtherside,但症状似乎相似

是否有方法获取更多信息以继续调试


我正在Linux Mint 18上运行Python 3.5.2。我的QT版本是5.7.0,PyQt版本是5.7,SIP版本是4.18.1。

兔子洞比我想象的要深。有一些问题

  • Linux Mint 18(可能是Ubuntu 16.04)存储库中的SIP版本太旧。我已更新到4.18.1
  • 有了更新的SIP版本,我可以。然而,在编译之前,我必须安装libqt5opengl5-dev,以便它可以使用QtOpenGL模块进行编译。编译后,我使用
    checkinstall
    进行安装,以使回滚更容易
  • 使用最新的SIP和PyQt5,我不再收到分段错误。然而,我遇到了OpenGL着色器无法正确创建的问题,只是收到了一个纯白色窗口

    的解决方法是在Python程序中加载PyQt之前包括以下内容:

    import ctypes
    from ctypes import util
    ctypes.CDLL(util.find_library('GL'), ctypes.RTLD_GLOBAL)
    
    我相信这是唯一的基于Ubuntu的操作系统与NVIDIA图形卡和二进制驱动程序