Deployed MATLAB Application not able to detect Python

3 ビュー (過去 30 日間)
Varun Pai
Varun Pai 2020 年 4 月 16 日
コメント済み: Varun Pai 2022 年 12 月 6 日
I have coded a MATLAB application which uses Python. When executing as code, there are no issues and the code is working fine.
But when the same application is deployed as an exe and executed, the application is unable to detect the Python distribution and error is returned.
I am getting the following warning and error
警告: Python コマンドには、サポートされているバージョンの CPython が必要です。「<a href="matlab:helpview([docroot '/matlab/helptargets.map'], 'getting_started_python_interface')">Python を使う</a>」を参照してください。
名前 py.numpy.array を解決できません。
Note : The numpy is working successfully from Python as well as from MATLAB code.
Environment :
MATLAB 2020a
Python 3.7.7 (added to system path)
Windows 10 64 bit
What could be the problem for this ? Appreciate any workarounds.
  2 件のコメント
Tazura1998
Tazura1998 2022 年 12 月 5 日
Hi Varun Pai,
I have the same problem right now, do you fix it?
Varun Pai
Varun Pai 2022 年 12 月 6 日
After loading Python in MATLAB using pyenv('Version', PythonPath), add PythonPath and <PythonPath>\Library\bin path to 'PATH' variable. Sample code
pyenv('Version', PythonExePath)
pyRootPath = fileparts(PythonExePath);
pathDelimiter = ';';
pathToAdd = {
fullfile(pyRootPath)
fullfile(pyRootPath, 'Library', 'bin')
};
ENV = getenv('PATH');
ENV = strsplit(ENV, pathDelimiter);
ENV = [pathToAdd(:); ENV(:)];
ENV = unique(ENV, 'stable');
ENV = strjoin(ENV, pathDelimiter);
setenv('PATH', ENV);
Note: If there are multiple Python in your PATH varibale, it may not work as expected.

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeCall Python from MATLAB についてさらに検索

タグ

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by