MATLAB Answers


Calling a python function from Matlab. Specific function error.

Asked by Rahaf Alenezi on 8 Dec 2018
Latest activity Answered by Saumya Goel on 18 Dec 2018
I am trying to call a python function in matlab. I tried the example provided in mathworks website which has a file called and a function search. I have another file with another function I want to run.. both in the same location.
The seems to work perfectly.. but the python file I have keeps giving me this error Undefined variable "py" or class
I do have to mention that this python code imports from pybrain which is installed on my computer.
I am running matlab on a mac.


Sign in to comment.




1 Answer

Answer by Saumya Goel on 18 Dec 2018

As per my understanding, this error message might occur due to some issue in user defined python script. You can try the below command:
>> py.importlib.import_module('ScriptName')
Also, you can go through this MATLAB documentation page, which suggests other possible reasons for the mentioned error message.


Sign in to comment.