Issues running python package example with matlab compiler SDK
14 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I am trying to figure out how to use Matlab Compiler SDK to package python scripts for the first time.
Right now, all I am attempting to do is run the example listed here: https://www.mathworks.com/help/compiler_sdk/gs/create-a-python-application-with-matlab-code.html
I have Matlab installed on my computer, and it has the compiler on it. When I go to my Applications folder, it shows a subfolder of matlab runtime there. Do I need to install matlab runtime? I ran the command mcrversion in my matlab, and it displays the number 9 which makes me assume I already have the runtime. Do I still need to download and install run time?
When I try to do the example shown here: https://www.mathworks.com/help/compiler_sdk/gs/create-a-python-application-with-matlab-code.html I go to the for_redistribution_files_only folder and type in python setup.py install. Next, I type python makesqrSample1.py. I get this error:
RuntimeError: On Mac, you must set the environment variable "DYLD_LIBRARY_PATH" to a non-empty string. For more details, see the package documentation.
I then tried setting DYLD_LIBRARY_PATH based on these instructions https://www.mathworks.com/help/matlab/matlab_external/set-run-time-library-path-on-mac-systems.html to the location of my MATLAB. I do that through these lines:
DYLD_LIBRARY_PATH=/Applications/MATLAB_R2020a.app/bin/maci64:/Applications/MATLAB_R2020a.app/sys/os/maci64:DYLD_LIBRARY_PATH
export DYLD_LIBRARY_PATH
Then, when I try to run python makesqrSample1.py I get this error:
RuntimeError: Could not find an appropriate directory for MATLAB or the MATLAB runtime in DYLD_LIBRARY_PATH. Details: libmwmclmcrrt.9.8.dylib
I also tried running mwpython makesqrSample1.py, since I am on a mac. When I do that, it says
-bash: mwpython: command not found
At this point I just don't know what is wrong, if I just don't have the correct things installed on my computer. etc.
Separately, I tried installing the Matlab Runtime, in case that was not in fact installed. I typed compiler.runtime.download in matlab to download the runtime installer because mcrinstaller said the installer could not be found (despite mcrversion saying I do have the runtime).
2 Commenti
Seongchun Yang
il 19 Ago 2020
Have you fixed the issue regarding DYLD_LIBRARY_PATH? It seems like while environment varaible itself is availabe, it isn't somehow in bash.
MacBook-Pro:~ seongchunyang$ echo $DYLD_LIBRARY_PATH
/Applications/MATLAB_R2020a.app/runtime/maci64:
bash-3.2$ echo $DYLD_LIBRARY_PATH
bash-3.2$
Alan Frankel
il 29 Dic 2022
I then tried setting DYLD_LIBRARY_PATH based on these instructions https://www.mathworks.com/help/matlab/matlab_external/set-run-time-library-path-on-mac-systems.html to the location of my MATLAB. I do that through these lines:
DYLD_LIBRARY_PATH=/Applications/MATLAB_R2020a.app/bin/maci64:/Applications/MATLAB_R2020a.app/sys/os/maci64:DYLD_LIBRARY_PATH
There is a typo in those instructions, which I have reported: There should be a dollar sign before the second instance of DYLD_LIBRARY_PATH. However, that's probably not the source of your problem. See whether it helps to replace "bin" with "runtime":
DYLD_LIBRARY_PATH=/Applications/MATLAB_R2020a.app/runtime/maci64:/Applications/MATLAB_R2020a.app/sys/os/maci64:$DYLD_LIBRARY_PATH
If it doesn't, try using both runtime/maci64 and bin/maci64:
DYLD_LIBRARY_PATH=/Applications/MATLAB_R2020a.app/runtime/maci64://Applications/MATLAB_R2020a.app/bin/maci64:/Applications/MATLAB_R2020a.app/sys/os/maci64:$DYLD_LIBRARY_PATH
Risposte (1)
Alan Frankel
il 5 Giu 2020
The error message is misleading, and has been fixed. On Mac, it should tell you to use mwpython. mwpython should be in <matlabroot>/bin for both MATLAB and the MATLAB Runtime.
It looks like when you have installed MATLAB, but not MATLAB Runtime, the command mcrversion tells you what the corresponding MATLAB Runtime version would be. The documentation could be more clear on this point, and I will report that. But in any case, installing MATLAB Runtime is not necessary for your situation.
2 Commenti
Luiza Silveira Voss De Gregorio
il 10 Set 2020
I am having practically the same issue. I have opened the mwpython exec in terminal and can import the module "MagicSquarePkg" in the terminal, but cannot do anything else. When I try to run the makesqrSample1.py or makesqr, I get:
>>> import MagicSquarePkg
>>> MagicSquarePkg.makesqr(5)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'makesqr'
I also get
-bash: mwpython: command not found
when I try to run
mwpython makesqrSample1.py
Is there anything that should be done before I call mwpython?
Alan Frankel
il 29 Dic 2022
If you want to use a specific version of Python, set the PYTHONHOME environment variable on your machine to point to the location of your desired Python installation prior to invoking mwpython.
Vedere anche
Categorie
Scopri di più su Python Package Integration in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!