フィルターのクリア

Is it possible to call from Matlab (with py) a Python code that itself call a Matlab function through matlab.engine ?

3 ビュー (過去 30 日間)
Hi evrybody
Everything's in the title so far !
I have a Python program using Matlab scripts through matlab module. Everything's fine when running directly from Python.
Then I try to use it from Matlab with py but I get the following error: "Python Error: ModuleNotFoundError: No module named 'matlab.engine'; 'matlab' is not a package"
Digging into mixing Matlab and Python since a short time, I've been discovering how powerfull are the offered functionalities... Would be great to be able to push further!
Any possibility to do that ?
Thanks in advance

回答 (1 件)

Gaurav Garg
Gaurav Garg 2019 年 9 月 16 日
Hi,
In my understanding, what you are trying to do is to execute a python code file in a MATLAB script. However, MATLAB provides support for selected functions/data types.
A possible workaround to the problem is to include the statements in a module and then try the steps defined in the link, or, you could also run an operating system command (system) and return the output.
  2 件のコメント
Eric Delgado
Eric Delgado 2021 年 2 月 22 日
@Gaurav Garg, I am having the same issue... I was calling a Python module inside Matlab, but I don't know what happened... it's not working anymore for some modules. For example, I still import "math module", but not "numpy module". It makes no sense (for me). Others posts about the same issue:
I run Matlab from Anaconda Prompt (wich put all Python folders and subfolders into Matlab path).
Eric Delgado
Eric Delgado 2021 年 2 月 22 日
Guys, I figure out what happened with my issue... I had two instances of Python installed on my computer. So Matlab was pointing to the raw version of Python (without Numpy and others modules).
So I just configure the right version of Python and it's allright now. :)
pyenv('Version', 'C:\ProgramData\Anaconda3\python.exe')

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

カテゴリ

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

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by