Error when using Gmsh Python API in 3D Slicer
I am trying to use Gmsh's Python API inside 3D Slicer.
When I try to import and initialize Gmsh from the Python console like this:
import gmsh
gmsh.initialize()
I get the following error:
error: [/media/useradmin/Disk2/Slicer-5.3.0-2023-01-21-linux-amd64/bin/SlicerApp-real] exit abnormally - Report the problem.
and the following GDB backtrace:
ben@p1:~$ gdb --pid 618067
GNU gdb (Debian 13.1-2) 13.1
Copyright (C) 2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
Attaching to process 618067
[New LWP 618068]
[New LWP 618069]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
0x00007f6783f1afff in poll () from /lib/x86_64-linux-gnu/libc.so.6
(gdb) continue
Continuing.
[New Thread 0x7f6723bff6c0 (LWP 618123)]
[New Thread 0x7f67233fe6c0 (LWP 618124)]
[New Thread 0x7f66fc5ff6c0 (LWP 618126)]
[New Thread 0x7f66f9dfe6c0 (LWP 618127)]
[New Thread 0x7f66f75fd6c0 (LWP 618128)]
[New Thread 0x7f66f4dfc6c0 (LWP 618129)]
[New Thread 0x7f66f45fb6c0 (LWP 618130)]
[New Thread 0x7f66f1dfa6c0 (LWP 618131)]
[New Thread 0x7f66ef5f96c0 (LWP 618132)]
[New Thread 0x7f66eadf86c0 (LWP 618133)]
[New Thread 0x7f66ea5f76c0 (LWP 618134)]
[New Thread 0x7f66e5df66c0 (LWP 618135)]
[New Thread 0x7f66e55f56c0 (LWP 618136)]
[New Thread 0x7f66dd5ff6c0 (LWP 618137)]
[New Thread 0x7f66dcdfe6c0 (LWP 618138)]
[New Thread 0x7f66d7fff6c0 (LWP 618139)]
[New Thread 0x7f669882b6c0 (LWP 618142)]
[New Thread 0x7f669802a6c0 (LWP 618143)]
[New Thread 0x7f66978296c0 (LWP 618144)]
[New Thread 0x7f66970286c0 (LWP 618145)]
[New Thread 0x7f66968276c0 (LWP 618146)]
[New Thread 0x7f66960266c0 (LWP 618147)]
[New Thread 0x7f66958256c0 (LWP 618148)]
[New Thread 0x7f66950246c0 (LWP 618149)]
[New Thread 0x7f66948236c0 (LWP 618150)]
[New Thread 0x7f666ffff6c0 (LWP 618151)]
[New Thread 0x7f666f7fe6c0 (LWP 618152)]
[New Thread 0x7f666effd6c0 (LWP 618153)]
[New Thread 0x7f664dbff6c0 (LWP 618154)]
[New Thread 0x7f664d3fe6c0 (LWP 618155)]
[Thread 0x7f669802a6c0 (LWP 618143) exited]
[Thread 0x7f66968276c0 (LWP 618146) exited]
[Thread 0x7f669882b6c0 (LWP 618142) exited]
[Thread 0x7f66948236c0 (LWP 618150) exited]
[Thread 0x7f666f7fe6c0 (LWP 618152) exited]
[Thread 0x7f66958256c0 (LWP 618148) exited]
[Thread 0x7f66960266c0 (LWP 618147) exited]
[Thread 0x7f666ffff6c0 (LWP 618151) exited]
[Thread 0x7f66950246c0 (LWP 618149) exited]
[Thread 0x7f66978296c0 (LWP 618144) exited]
[Thread 0x7f666effd6c0 (LWP 618153) exited]
[Thread 0x7f66970286c0 (LWP 618145) exited]
[New Thread 0x7f66970286c0 (LWP 618157)]
[New Thread 0x7f666effd6c0 (LWP 618158)]
[New Thread 0x7f66950246c0 (LWP 618159)]
[New Thread 0x7f66978296c0 (LWP 618160)]
[New Thread 0x7f669882b6c0 (LWP 618161)]
[New Thread 0x7f669802a6c0 (LWP 618162)]
[New Thread 0x7f66968276c0 (LWP 618163)]
[New Thread 0x7f66960266c0 (LWP 618164)]
[New Thread 0x7f66958256c0 (LWP 618165)]
[New Thread 0x7f66948236c0 (LWP 618166)]
[New Thread 0x7f666ffff6c0 (LWP 618167)]
Thread 1 "SlicerApp-real" received signal SIGABRT, Aborted.
0x00007f6783ea9ccc in ?? () from /lib/x86_64-linux-gnu/libc.so.6
(gdb) backtrace
#0 0x00007f6783ea9ccc in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#1 0x00007f6783e5aef2 in raise () from /lib/x86_64-linux-gnu/libc.so.6
#2 0x00007f6783e45472 in abort () from /lib/x86_64-linux-gnu/libc.so.6
#3 0x00007f6783e9e2d0 in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#4 0x00007f6783eb364a in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#5 0x00007f6783eb53d4 in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#6 0x00007f6783eb7d2f in free () from /lib/x86_64-linux-gnu/libc.so.6
#7 0x00007f663791b09f in std::__detail::_Compiler<std::__cxx11::regex_traits<char> >::_Compiler(char const*, char const*, std::locale const&, std::regex_constants::syntax_option_type) ()
from /opt/slicer/Slicer-5.2.2-linux-amd64/lib/Python/lib/libgmsh.so.4.11
#8 0x00007f663791b158 in std::enable_if<std::__detail::__is_contiguous_normal_iter<char const*>::value, std::shared_ptr<std::__detail::_NFA<std::__cxx11::regex_traits<char> > const> >::type std::__detail::__compile_nfa<char const*, std::__cxx11::regex_traits<char> >(char const*, char const*, std::__cxx11::regex_traits<char>::locale_type const&, std::regex_constants::syntax_option_type) () from /opt/slicer/Slicer-5.2.2-linux-amd64/lib/Python/lib/libgmsh.so.4.11
#9 0x00007f6637909bcb in ?? () from /opt/slicer/Slicer-5.2.2-linux-amd64/lib/Python/lib/libgmsh.so.4.11
#10 0x00007f6637909d53 in ?? () from /opt/slicer/Slicer-5.2.2-linux-amd64/lib/Python/lib/libgmsh.so.4.11
#11 0x00007f66378e1b1e in ?? () from /opt/slicer/Slicer-5.2.2-linux-amd64/lib/Python/lib/libgmsh.so.4.11
#12 0x00007f66378bee91 in ?? () from /opt/slicer/Slicer-5.2.2-linux-amd64/lib/Python/lib/libgmsh.so.4.11
#13 0x00007f66378df65a in ?? () from /opt/slicer/Slicer-5.2.2-linux-amd64/lib/Python/lib/libgmsh.so.4.11
#14 0x00007f663789dcae in ?? () from /opt/slicer/Slicer-5.2.2-linux-amd64/lib/Python/lib/libgmsh.so.4.11
#15 0x00007f6637933205 in gmsh::initialize(int, char**, bool, bool) () from /opt/slicer/Slicer-5.2.2-linux-amd64/lib/Python/lib/libgmsh.so.4.11
#16 0x00007f663857a1d5 in gmshInitialize () from /opt/slicer/Slicer-5.2.2-linux-amd64/lib/Python/lib/libgmsh.so.4.11
#17 0x00007f674a4be052 in ?? () from /opt/slicer/Slicer-5.2.2-linux-amd64/bin/../lib/Python/lib/libpython3.9.so
#18 0x00007f674a4bb64e in ?? () from /opt/slicer/Slicer-5.2.2-linux-amd64/bin/../lib/Python/lib/libpython3.9.so
#19 0x00007f674a4b199d in _ctypes_callproc () from /opt/slicer/Slicer-5.2.2-linux-amd64/bin/../lib/Python/lib/libpython3.9.so
#20 0x00007f674a4aaa76 in ?? () from /opt/slicer/Slicer-5.2.2-linux-amd64/bin/../lib/Python/lib/libpython3.9.so
#21 0x00007f674a297e5a in _PyObject_MakeTpCall () from /opt/slicer/Slicer-5.2.2-linux-amd64/bin/../lib/Python/lib/libpython3.9.so
#22 0x00007f674a2765fb in ?? () from /opt/slicer/Slicer-5.2.2-linux-amd64/bin/../lib/Python/lib/libpython3.9.so
#23 0x00007f674a27d070 in _PyEval_EvalFrameDefault () from /opt/slicer/Slicer-5.2.2-linux-amd64/bin/../lib/Python/lib/libpython3.9.so
#24 0x00007f674a27542b in ?? () from /opt/slicer/Slicer-5.2.2-linux-amd64/bin/../lib/Python/lib/libpython3.9.so
#25 0x00007f674a276597 in ?? () from /opt/slicer/Slicer-5.2.2-linux-amd64/bin/../lib/Python/lib/libpython3.9.so
#26 0x00007f674a27d070 in _PyEval_EvalFrameDefault () from /opt/slicer/Slicer-5.2.2-linux-amd64/bin/../lib/Python/lib/libpython3.9.so
#27 0x00007f674a3c0b37 in _PyEval_EvalCode () from /opt/slicer/Slicer-5.2.2-linux-amd64/bin/../lib/Python/lib/libpython3.9.so
#28 0x00007f674a3c0ed2 in _PyEval_EvalCodeWithName () from /opt/slicer/Slicer-5.2.2-linux-amd64/bin/../lib/Python/lib/libpython3.9.so
#29 0x00007f674a3c0f1e in PyEval_EvalCodeEx () from /opt/slicer/Slicer-5.2.2-linux-amd64/bin/../lib/Python/lib/libpython3.9.so
#30 0x00007f674a3c0f4b in PyEval_EvalCode () from /opt/slicer/Slicer-5.2.2-linux-amd64/bin/../lib/Python/lib/libpython3.9.so
#31 0x00007f674a3bbd41 in ?? () from /opt/slicer/Slicer-5.2.2-linux-amd64/bin/../lib/Python/lib/libpython3.9.so
#32 0x00007f674a302f15 in ?? () from /opt/slicer/Slicer-5.2.2-linux-amd64/bin/../lib/Python/lib/libpython3.9.so
#33 0x00007f674a27c101 in _PyEval_EvalFrameDefault () from /opt/slicer/Slicer-5.2.2-linux-amd64/bin/../lib/Python/lib/libpython3.9.so
#34 0x00007f674a27542b in ?? () from /opt/slicer/Slicer-5.2.2-linux-amd64/bin/../lib/Python/lib/libpython3.9.so
#35 0x00007f674a276597 in ?? () from /opt/slicer/Slicer-5.2.2-linux-amd64/bin/../lib/Python/lib/libpython3.9.so
#36 0x00007f674a277fa2 in _PyEval_EvalFrameDefault () from /opt/slicer/Slicer-5.2.2-linux-amd64/bin/../lib/Python/lib/libpython3.9.so
#37 0x00007f674a3c0b37 in _PyEval_EvalCode () from /opt/slicer/Slicer-5.2.2-linux-amd64/bin/../lib/Python/lib/libpython3.9.so
#38 0x00007f674a297c41 in _PyFunction_Vectorcall () from /opt/slicer/Slicer-5.2.2-linux-amd64/bin/../lib/Python/lib/libpython3.9.so
#39 0x00007f674a276597 in ?? () from /opt/slicer/Slicer-5.2.2-linux-amd64/bin/../lib/Python/lib/libpython3.9.so
#40 0x00007f674a277fa2 in _PyEval_EvalFrameDefault () from /opt/slicer/Slicer-5.2.2-linux-amd64/bin/../lib/Python/lib/libpython3.9.so
#41 0x00007f674a27542b in ?? () from /opt/slicer/Slicer-5.2.2-linux-amd64/bin/../lib/Python/lib/libpython3.9.so
#42 0x00007f674a2b0586 in ?? () from /opt/slicer/Slicer-5.2.2-linux-amd64/bin/../lib/Python/lib/libpython3.9.so
#43 0x00007f674a29a19c in PyObject_CallMethod () from /opt/slicer/Slicer-5.2.2-linux-amd64/bin/../lib/Python/lib/libpython3.9.so
#44 0x00007f6783c083ea in ?? () from /opt/slicer/Slicer-5.2.2-linux-amd64/bin/../lib/Slicer-5.2/libCTKScriptingPythonWidgets.so.0.1
#45 0x00007f6783c08b51 in ctkPythonConsole::executeCommand(QString const&) () from /opt/slicer/Slicer-5.2.2-linux-amd64/bin/../lib/Slicer-5.2/libCTKScriptingPythonWidgets.so.0.1
#46 0x00007f67832cd359 in ctkConsolePrivate::internalExecuteCommand() () from /opt/slicer/Slicer-5.2.2-linux-amd64/bin/../lib/Slicer-5.2/libCTKWidgets.so.0.1
#47 0x00007f67832ce941 in ctkConsolePrivate::keyPressEvent(QKeyEvent*) () from /opt/slicer/Slicer-5.2.2-linux-amd64/bin/../lib/Slicer-5.2/libCTKWidgets.so.0.1
#48 0x00007f67821a20a7 in QWidget::event(QEvent*) () from /opt/slicer/Slicer-5.2.2-linux-amd64/bin/../lib/Slicer-5.2/libQt5Widgets.so.5
#49 0x00007f678224a21e in QFrame::event(QEvent*) () from /opt/slicer/Slicer-5.2.2-linux-amd64/bin/../lib/Slicer-5.2/libQt5Widgets.so.5
#50 0x00007f678224cef3 in QAbstractScrollArea::event(QEvent*) () from /opt/slicer/Slicer-5.2.2-linux-amd64/bin/../lib/Slicer-5.2/libQt5Widgets.so.5
--Type <RET> for more, q to quit, c to continue without paging--c
#51 0x00007f6782318f7a in QTextEdit::event(QEvent*) () from /opt/slicer/Slicer-5.2.2-linux-amd64/bin/../lib/Slicer-5.2/libQt5Widgets.so.5
#52 0x00007f678216343c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /opt/slicer/Slicer-5.2.2-linux-amd64/bin/../lib/Slicer-5.2/libQt5Widgets.so.5
#53 0x00007f678216ab55 in QApplication::notify(QObject*, QEvent*) () from /opt/slicer/Slicer-5.2.2-linux-amd64/bin/../lib/Slicer-5.2/libQt5Widgets.so.5
#54 0x00007f6784e8b3b6 in qSlicerApplication::notify(QObject*, QEvent*) () from /opt/slicer/Slicer-5.2.2-linux-amd64/bin/../lib/Slicer-5.2/libqSlicerBaseQTGUI.so
#55 0x00007f678109d808 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from /opt/slicer/Slicer-5.2.2-linux-amd64/bin/../lib/Slicer-5.2/libQt5Core.so.5
#56 0x00007f67821bdd0b in ?? () from /opt/slicer/Slicer-5.2.2-linux-amd64/bin/../lib/Slicer-5.2/libQt5Widgets.so.5
#57 0x00007f678216343c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /opt/slicer/Slicer-5.2.2-linux-amd64/bin/../lib/Slicer-5.2/libQt5Widgets.so.5
#58 0x00007f6782169f20 in QApplication::notify(QObject*, QEvent*) () from /opt/slicer/Slicer-5.2.2-linux-amd64/bin/../lib/Slicer-5.2/libQt5Widgets.so.5
#59 0x00007f6784e8b3b6 in qSlicerApplication::notify(QObject*, QEvent*) () from /opt/slicer/Slicer-5.2.2-linux-amd64/bin/../lib/Slicer-5.2/libqSlicerBaseQTGUI.so
#60 0x00007f678109d808 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from /opt/slicer/Slicer-5.2.2-linux-amd64/bin/../lib/Slicer-5.2/libQt5Core.so.5
#61 0x00007f678176be1b in QGuiApplicationPrivate::processKeyEvent(QWindowSystemInterfacePrivate::KeyEvent*) () from /opt/slicer/Slicer-5.2.2-linux-amd64/bin/../lib/Slicer-5.2/libQt5Gui.so.5
#62 0x00007f6781770935 in QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent*) () from /opt/slicer/Slicer-5.2.2-linux-amd64/bin/../lib/Slicer-5.2/libQt5Gui.so.5
#63 0x00007f678174c8ab in QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /opt/slicer/Slicer-5.2.2-linux-amd64/bin/../lib/Slicer-5.2/libQt5Gui.so.5
#64 0x00007f673466569a in ?? () from /opt/slicer/Slicer-5.2.2-linux-amd64/bin/../lib/Slicer-5.2/libQt5XcbQpa.so.5
#65 0x00007f678571c7a9 in g_main_context_dispatch () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#66 0x00007f678571ca38 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#67 0x00007f678571cacc in g_main_context_iteration () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#68 0x00007f67810f91cc in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /opt/slicer/Slicer-5.2.2-linux-amd64/bin/../lib/Slicer-5.2/libQt5Core.so.5
#69 0x00007f678109c21a in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /opt/slicer/Slicer-5.2.2-linux-amd64/bin/../lib/Slicer-5.2/libQt5Core.so.5
#70 0x00007f67810a51d3 in QCoreApplication::exec() () from /opt/slicer/Slicer-5.2.2-linux-amd64/bin/../lib/Slicer-5.2/libQt5Core.so.5
#71 0x00007f6782a5361a in qSlicerCoreApplication::exec() () from /opt/slicer/Slicer-5.2.2-linux-amd64/bin/../lib/Slicer-5.2/libqSlicerBaseQTCore.so
#72 0x0000000000404a77 in ?? ()
#73 0x00007f6783e4618a in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#74 0x00007f6783e46245 in __libc_start_main () from /lib/x86_64-linux-gnu/libc.so.6
#75 0x0000000000404b6c in ?? ()
(gdb)
I have contacted the 3D Slicer developers here: https://discourse.slicer.org/t/cannot-import-gmsh-python-package/29344
Their analysis found that 3D Slicer and Gmsh use incompatible GCC ABI options.
Do you have any suggestions on how to get the Gmsh Python API working within 3D Slicer?