Unable to run mwpython

15 views (last 30 days)
Thomas Morrell
Thomas Morrell on 11 Nov 2021
Commented: scivision on 29 Nov 2023
Hi, I recently received a Python library compiled using the MATLAB Compiler by a collaborator (in MATLAB R2021b), and am currently unable to run it. I saw that on MacOS (I'm running v12.0.1 Monterey on an M1 processor using Rosetta 2 for compatibility), a special mwpython application is needed instead of calling the system python. I installed v9.11 of the MATLAB Runtime and followed directions for adding to the DYLD_LIBRARY_PATH. When I run /<abs_path_to_app>/mwpython3.9, however, the following error message is displayed:
dyld[17284]: Library not loaded: @rpath/libpython3.9.dylib
Referenced from: /Applications/MATLAB/MATLAB_Runtime/v911/bin/maci64/mwpython3.9.app/Contents/MacOS/mwpython3.9
Reason: tried: '/Applications/MATLAB/MATLAB_Runtime/v911/runtime/maci64/libpython3.9.dylib' (no such file), '/Applications/MATLAB/MATLAB_Runtime/v911/sys/os/maci64/libpython3.9.dylib' (no such file), '/Applications/MATLAB/MATLAB_Runtime/v911/bin/maci64/libpython3.9.dylib' (no such file), '/Applications/MATLAB/MATLAB_Runtime/v911/extern/bin/maci64/libpython3.9.dylib' (no such file), '/Applications/MATLAB/MATLAB_Runtime/v911/bin/maci64/mwpython3.9.app/Contents/MacOS/libpython3.9.dylib' (no such file), '/Applications/MATLAB/MATLAB_Runtime/v911/bin/maci64/mwpython3.9.app/Contents/MacOS/./libpython3.9.dylib' (no such file), '/Applications/MATLAB/MATLAB_Runtime/v911/bin/maci64/mwpython3.9.app/Contents/MacOS/../../../../../bin/maci64/libpython3.9.dylib' (no such file), '/Applications/MATLAB/MATLAB_Runtime/v911/bin/maci64/mwpython3.9.app/Contents/MacOS/../../../../../sys/os/maci64/libpython3.9.dylib' (no such file), '/Library/Frameworks/Python.framework/Versions/3.9/lib/libpython3.9.dylib' (no such file), '/Applications/MATLAB/MATLAB_Runtime/v911/bin/maci64/mwpython3.9.app/Contents/MacOS/libpython3.9.dylib' (no such file), '/Applications/MATLAB/MATLAB_Runtime/v911/bin/maci64/mwpython3.9.app/Contents/MacOS/./libpython3.9.dylib' (no such file), '/Applications/MATLAB/MATLAB_Runtime/v911/bin/maci64/mwpython3.9.app/Contents/MacOS/../../../../../bin/maci64/libpython3.9.dylib' (no such file), '/Applications/MATLAB/MATLAB_Runtime/v911/bin/maci64/mwpython3.9.app/Contents/MacOS/../../../../../sys/os/maci64/libpython3.9.dylib' (no such file), '/Library/Frameworks/Python.framework/Versions/3.9/lib/libpython3.9.dylib' (no such file), '/usr/local/lib/libpython3.9.dylib' (no such file), '/usr/lib/libpython3.9.dylib' (no such file)
Abort trap: 6
It appears that libpython3.9.dylib was not included in the installation of the MATLAB Runtime. Is there a way to get it or work around the issue? Thanks in advance.
  1 Comment
scivision
scivision on 29 Nov 2023
I fixed this error message by "conda deactivate" in the Terminal session I'm using. I do this each time I start a new Terminal where I want to use "mwpython".

Sign in to comment.

Answers (1)

Thomas Morrell
Thomas Morrell on 11 Nov 2021
I figured it out. When the M1 processor first came out, miniforge was the preferred build environment, and I had installed Python through that. However, this installs Python in a different location than MATLAB expects. Installing Python in the standard location in x86 compatibility mode fixes the problem.
It is also worth noting that at least one Python package created via the MATLAB compiler needs to be installed before it is possible to run mwpython without error.
  1 Comment
Hovav Lazare
Hovav Lazare on 30 Aug 2023
how do you Installing Python in the standard location in x86 compatibility mode on M1?

Sign in to comment.

Categories

Find more on Python Package Integration in Help Center and File Exchange

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!