1

I'm using

  • Mac OSX High Sierra
  • anaconda3 python (virtual environment with python=3.6)
  • Matlab R2018a.

Steps to reproduce:

  1. Create a new python 3.6 environment. Activate the environment
  2. Go to Matlab/extern/engines/python and run python setup.py install.
  3. Run the following script.
import matlab.engine
matlab.engine.start_matlab()

Segmentation fault happen at the start_matlab() line (not the import line). I had no trouble before using matlab engine this way. How could I debug this? (mostly is just linking problem).

======================

I uninstalled Anaconda3, and used Python 2.7 system. I met with the same problem, and the problem is with libwmvm.dylib of Matlab.

    Process:               Python [5124]
Path:                  /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
Identifier:            Python
Version:               2.7.10 (2.7.10)
Code Type:             X86-64 (Native)
Parent Process:        bash [2183]
Responsible:           Python [5124]
User ID:               501

PlugIn Path:             /Applications/MATLAB_R2018a.app/bin/maci64/libmwmvm.dylib
PlugIn Identifier:       libmwmvm.dylib
PlugIn Version:          ??? (0)

Date/Time:             2018-04-27 23:27:03.250 +0700
OS Version:            Mac OS X 10.13.4 (17E199)
Report Version:        12
Anonymous UUID:        885790DC-B32C-0363-903C-837A7C285AF3

Sleep/Wake UUID:       14FBD560-D2B9-4A59-89F1-DABA878FCA70

Time Awake Since Boot: 10000 seconds
Time Since Wake:       3700 seconds

System Integrity Protection: enabled

Crashed Thread:        3

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       KERN_INVALID_ADDRESS at 0x0000000000000090
Exception Note:        EXC_CORPSE_NOTIFY

Termination Signal:    Segmentation fault: 11
Termination Reason:    Namespace SIGNAL, Code 0xb
Terminating Process:   exc handler [0]

VM Regions Near 0x90:
--> 
    __TEXT                 000000010e1c6000-000000010e1c8000 [    8K] r-x/rwx SM=COW  p [/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python]

Thread 0:: Dispatch queue: com.apple.main-thread
Dzung Nguyen
  • 3,794
  • 9
  • 48
  • 86
  • 1
    I'm not Mac OSX user, but probably you can use `strace` to see the list of syscalls performed until the segmentation fault, and use the output information to discover what's going wrong. – aicastell Apr 27 '18 at 10:19
  • 1
    I would recommend using `top` command on another terminal and check if you're running out of memory. Segmentation faults can also happen if you've already loaded your memory – Sidharth Shah Apr 27 '18 at 10:22
  • 1
    I just tried the exact same thing you did and couldn't reproduce, it worked without segfault. High Sierra 10.13.4 (17E199), Matlab R2018a, Python 3.6.4 (managed by pyenv, though it shouldn't matter that it's not Conda right?), virtualenv. Mayyybe you could try 3.6 through [pyenv](https://github.com/pyenv/pyenv#homebrew-on-mac-os-x) (or system-wide install) to see if its a Conda-specific thing? – Ahmed Fasih Apr 27 '18 at 13:38

1 Answers1

1

Matlab engine is not supported by python 3.6, you can use python 3.5.

I have anaconda, python 2.7, 3.5 and 3.6 also. You can easily differentiate between them by renaming the python.exe to python35.exe for instance. Than you can call you py srcipt like this:

python35 example.py

And it will call it with python35.

Hint: pip install and conda install won't work after the renaming, since it's searching for python.exe, so you don't have to rename the anaconda and the python version what you are using in most of the case.