pyQt5 and python3 crash segfault

After installing pyQt5 on ubuntu 18.04 through several methods

  • synaptic python3-pyqt5
  • pip3 install -user pyqt5

with all methods I get a segfault launching the following code: python3

from PyQt5.QtWidgets import QApplication app = QApplication([]) Segmentation fault (core dumped) 

Note that with python2 and pyqt5 it works. Launching gdb I can track down the problem to the libQt5XcbQpa.so.5 qt5 library:

>>> from PyQt5.QtWidgets import QApplication, QLabel >>> app = QApplication([]) [New Thread 0x7fffe9fc0700 (LWP 7142)]  Thread 1 "python3" received signal SIGSEGV, Segmentation fault. 0x00007fffee51db28 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5XcbQpa.so.5 (gdb) bt #0  0x00007fffee51db28 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5XcbQpa.so.5 #1  0x00007fffee509650 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5XcbQpa.so.5 #2  0x00007fffee509728 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5XcbQpa.so.5 #3  0x00007fffee4fedf9 in QXcbConnection::QXcbConnection(QXcbNativeInterface*, bool, unsigned int, char const*) () from /usr/lib/x86_64-linux-gnu/libQt5XcbQpa.so.5 #4  0x00007fffee5024be in QXcbIntegration::QXcbIntegration(QStringList const&, int&, char**) () from /usr/lib/x86_64-linux-gnu/libQt5XcbQpa.so.5 #5  0x00007fffee7c562d in QXcbIntegrationPlugin::create(QString const&, QStringList const&, int&, char**) ()    from /home/manu/.local/lib/python3.6/site-packages/PyQt5/Qt/plugins/platforms/libqxcb.so #6  0x00007ffff44815eb in QPlatformIntegrationFactory::create(QString const&, QStringList const&, int&, char**, QString const&) ()    from /home/manu/.local/lib/python3.6/site-packages/PyQt5/Qt/lib/libQt5Gui.so.5 #7  0x00007ffff448e8f7 in QGuiApplicationPrivate::createPlatformIntegration() () from /home/manu/.local/lib/python3.6/site-packages/PyQt5/Qt/lib/libQt5Gui.so.5 #8  0x00007ffff448f9dd in QGuiApplicationPrivate::createEventDispatcher() () from /home/manu/.local/lib/python3.6/site-packages/PyQt5/Qt/lib/libQt5Gui.so.5 #9  0x00007ffff3e332ff in QCoreApplicationPrivate::init() () from /home/manu/.local/lib/python3.6/site-packages/PyQt5/Qt/lib/libQt5Core.so.5 #10 0x00007ffff449130b in QGuiApplicationPrivate::init() () from /home/manu/.local/lib/python3.6/site-packages/PyQt5/Qt/lib/libQt5Gui.so.5 #11 0x00007ffff4cda1d9 in QApplicationPrivate::init() () from /home/manu/.local/lib/python3.6/site-packages/PyQt5/Qt/lib/libQt5Widgets.so.5 #12 0x00007ffff5611269 in sipQApplication::sipQApplication(int&, char**, int) () from /home/manu/.local/lib/python3.6/site-packages/PyQt5/QtWidgets.so #13 0x00007ffff5611339 in init_type_QApplication () from /home/manu/.local/lib/python3.6/site-packages/PyQt5/QtWidgets.so #14 0x00007fffef551c74 in sipSimpleWrapper_init () from /home/manu/.local/lib/python3.6/site-packages/PyQt5/sip.so #15 0x0000000000555421 in type_call.lto_priv () at ../Objects/typeobject.c:915 #16 0x00000000005a730c in _PyObject_FastCallDict (kwargs=<optimized out>, nargs=<optimized out>, args=<optimized out>, func=<sip.wrappertype at remote 0xc808b8>)     at ../Objects/tupleobject.c:131 #17 _PyObject_FastCallKeywords () at ../Objects/abstract.c:2496 #18 0x0000000000503073 in call_function.lto_priv () at ../Python/ceval.c:4861 #19 0x0000000000506859 in _PyEval_EvalFrameDefault () at ../Python/ceval.c:3335 #20 0x0000000000504c28 in PyEval_EvalFrameEx (throwflag=0, f=Frame 0xaeaa18, for file <stdin>, line 1, in <module> ()) at ../Python/ceval.c:4166 #21 _PyEval_EvalCodeWithName.lto_priv.1761 () at ../Python/ceval.c:4166 #22 0x0000000000506393 in PyEval_EvalCodeEx (closure=0x0, kwdefs=0x0, defcount=0, defs=0x0, kwcount=0, kws=0x0, argcount=0, args=0x0, locals=<optimized out>, globals=<optimized out>,      _co=<optimized out>) at ../Python/ceval.c:4187 #23 PyEval_EvalCode (co=<optimized out>, globals=<optimized out>, locals=<optimized out>) at ../Python/ceval.c:731 #24 0x0000000000634d52 in run_mod () at ../Python/pythonrun.c:1025 #25 0x00000000004a38c5 in PyRun_InteractiveOneObjectEx (fp=fp@entry=0x7ffff7dcfa00 <_IO_2_1_stdin_>, filename=filename@entry='<stdin>', flags=flags@entry=0x7fffffffcdbc)     at ../Python/pythonrun.c:246 #26 0x00000000004a5cd5 in PyRun_InteractiveLoopFlags (fp=fp@entry=0x7ffff7dcfa00 <_IO_2_1_stdin_>, filename_str=filename_str@entry=0x7541e0 "<stdin>",      flags=flags@entry=0x7fffffffcdbc) at ../Python/pythonrun.c:114 #27 0x00000000006387b3 in PyRun_AnyFileExFlags () at ../Python/pythonrun.c:75 #28 0x000000000063915a in run_file (p_cf=0x7fffffffcdbc, filename=<optimized out>, fp=<optimized out>) at ../Modules/main.c:340 #29 Py_Main () at ../Modules/main.c:810 #30 0x00000000004a6f10 in main (argc=1, argv=0x7fffffffcfb8) at ../Programs/python.c:69 

Unfortunately I need python3 and pyqt5 working (cadquery and cq-editor). Does anyone have a clue what the problem might be ?