Segmentation Fault when using MATLAB Engine with RHEL or CentOS Linux

44 visualizzazioni (ultimi 30 giorni)
When I run this simple script using MATLAB Engine for Python on RHEL (or Centos) Linux, I get a Segmentation Fault.
import matlab.engine
eng=matlab.engine.start_matlab()
eng.sqrt(4.)
Sometimes, instead of a Segmentation fault, I get the following type of error.
"libstdc++.so.6: undefined symbol: __cxa_thread_atexit_impl"
How can I fix these errors when using MATLAB Engine with RHEL 7 (or Centos 7) Linux?

Risposta accettata

MathWorks Support Team
MathWorks Support Team il 7 Mar 2024
There can be an incompatibility of the C runtime for MATLAB Engine on some RedHat and CentOS Linux operating systems. If that is the case, forcing Python Engine to load the shim library will fix the issue. Follow the steps below to preload the shim library.
On the Linux machine:
Find the path to the MATLAB root folder. This path can be displayed by typing the following command in the MATLAB Command Window.
>> matlabroot
Substitute this path for matlabroot  in the commands below.
In a Linux terminal, determine the name of the shim library
ls matlabroot/bin/glnxa64/glibc-*
Determine the name of the shim library
ls matlabroot/bin/glnxa64/glibc-*
Determine which type of terminal is being used.
echo $0
For a csh/tcsh terminal, execute the following command (this example assumes 2.17 version of the shim library)
setenv LD_PRELOAD matlabroot/bin/glnxa64/glibc-2.17_shim.so
For a bash terminal, execute the following command.
export LD_PRELOAD=matlabroot/bin/glnxa64/glibc-2.17_shim.so
Run the Python code in the same terminal.

Più risposte (0)

Categorie

Scopri di più su Python Package Integration in Help Center e File Exchange

Tag

Non è stata ancora inserito alcun tag.

Prodotti

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by