In trying to get a very basic PyQt5 QML example to run, I found that I get a segmentation fault. I verified that it only seems deal with displaying QML since an example without a window runs fine. I tried the following minimial test:
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")
import QtQuick 2.5
import QtQuick.Controls 1.4
(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*) ()
#2 0x00007fffe273e979 in ?? ()
#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
The rabbit hole went deeper than I thought. There were a few problems.
checkinstallto make rolling back easier.
With the latest SIP and PyQt5, I no longer received the segmentation fault. However, I had issues with the OpenGL shaders not being created properly and just received a plain white window.
The workaround for this bug is to include the following before loading PyQt in the Python program:
import ctypes from ctypes import util ctypes.CDLL(util.find_library('GL'), ctypes.RTLD_GLOBAL)
I believe this is unique to Ubuntu-based OSs with NVIDIA graphics cards and binary drivers.