Use Matlab with not supported Py3.x version (e.g. ML 2021a with Py 3.9)?

조회 수: 1 (최근 30일)
Henning
Henning 2022년 8월 4일
댓글: Walter Roberson 2022년 8월 4일
I would like to use Matlab 2021a with py3.9. Unfortunately there 2021a only supports py 3.7 and 3.8. Is there any possibilty to enable ml 2021a to work with py 3.9?

답변 (1개)

Walter Roberson
Walter Roberson 2022년 8월 4일
Yes, of course there is a possibility.
Python is open source code. You can get a copy of the 3.9 code and alter the numbering and recompile it, and install your customized version.
How well it will work...
  댓글 수: 5
Walter Roberson
Walter Roberson 2022년 8월 4일
편집: Walter Roberson 2022년 8월 4일
pyenv is built-in code, so you would have to figure out what it is supposed to do, and write your own version of it. You would place your version earlier on the path than the Mathworks version: files earlier on the path are used intead of files later on the path (generally speaking.)
pe = pyenv
pe =
PythonEnvironment with properties: Version: "2.7" Executable: "/usr/bin/python" Library: "libpython2.7.so.1.0" Home: "/usr" Status: NotLoaded ExecutionMode: InProcess
It might be a bit tricky to create an object of the right class
which -all pyenv
built-in (/MATLAB/toolbox/matlab/external/interfaces/python/pyenv)
!find /MATLAB/toolbox/matlab -name \*PythonEnvironment\* -print
/MATLAB/toolbox/matlab/external/interfaces/python/+matlab/+pyclient/@PythonEnvironment /MATLAB/toolbox/matlab/external/interfaces/python/+matlab/+pyclient/PythonEnvironment.m
Walter Roberson
Walter Roberson 2022년 8월 4일
It looks like possibly it uses
toolbox/matlab/external/interfaces/python/+python/+internal/pyinfo.m
which tells the python executable to run pyinfo.py to return information about the execution environment.
If that is what is getting invoked internally, then overriding it will take a bit of work. Earlier I said "generally speaking", but when that + folder structure is used and the internal code uses dot separated names like python.internal.pyinfo('C:\Python33\python.exe'), then that overrides the path for the most part... you would need to replace the entire python class to override an internal execution of python.internal.pyinfo (unless you executed the pyinfo.py into something that lied for you.)

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Call Python from MATLAB에 대해 자세히 알아보기

태그

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by