Recursive calls Matlab <--> Python

1 次查看(过去 30 天)
Lucas Carneiro
Lucas Carneiro 2018-3-19
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:
matlab.engine.shareEngine
py.importlib.import_module('call_python_pso')
py.call_python_pso.execute_pso()
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
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