Recursive calls Matlab <--> Python

조회 수: 1 (최근 30일)
Lucas Carneiro
Lucas Carneiro 2018년 3월 19일
댓글: Ahmed Abida 2021년 3월 12일
I want to call a python script from Matlab. At the same time, this python script will perform recursive calls to Matlab scripts.
Here is how it is implemented in Matlab:
In Python:
import matlab.engine
from pyswarm import pso
import sys
The error I get in py.importlib.import_module('call_python_pso'):
Error using enginesession>__init__ (line 8)
Python Error: EngineError: MATLAB process session cannot be initialized.
Error in __init__><module> (line 82)
_session = EngineSession()
Error in call_python_pso><module> (line 1)
import matlab.engine
Error in <frozen importlib>_call_with_frames_removed (line 219)
Error in <frozen importlib>exec_module (line 678)
Error in <frozen importlib>_load_unlocked (line 665)
Error in <frozen importlib>_find_and_load_unlocked (line 955)
Error in <frozen importlib>_find_and_load (line 971)
Error in <frozen importlib>_gcd_import (line 994)
Error in __init__>import_module (line 126)
return _bootstrap._gcd_import(name[level:], package, level)
Is this really possible to be accomplished: Matlab<-->Python? It seems that half of a dozen persons raised this same question in the forum but I could not identify convenient answers.
Matlab R2018a + Anaconda Python 3.5 Thanks in advance, Lucas

답변 (1개)

NISARGA G K 2018년 3월 22일
Calling Python Script that imports the Matlab python engine is not a supported workflow.
  댓글 수: 1
Ahmed Abida
Ahmed Abida 2021년 3월 12일
Hallo NISARGA and Lucas, is there any documentation/link for it ? the same pb is happening Matlab2020b + python3.6

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


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

Community Treasure Hunt

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

Start Hunting!

Translated by