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

2 ビュー (過去 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 Center および File ExchangePython Package Integration についてさらに検索

タグ

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by