Using matlab engine in python, error with config_io
9 views (last 30 days)
Show older comments
Hi everyone,
I am currently setting up a matlab engine on python. It is working fine and I could launch some matlab scripts from python.
Yet, there are one specific matlab script that I CANNOT run from python as I get this error :
Unrecognized function or variable 'config_io'.
I do not read any error when running the script directly from matlab, nor do I when I run the script from matlab engine on python while removing that specific line.
Any advice on how to fix this ? The line config_io is really important to my script as I am working with EEG and triggers... Should I try to find a way to use config_io in python before launching the matlab engine ?
(Using matlab 2022b and python 3.11 on Windows)
Thanks in advance fro your answers,
Regards.
0 Comments
Accepted Answer
Shubham
on 3 Apr 2023
Hi Soraya,
The error you are encountering is due to a missing function or variable in your MATLAB path when running the script from Python. The function or variable 'config_io' might not be accessible from the MATLAB engine when running the script from Python.
One possible solution could be to add the directory containing the necessary MATLAB function or variable to your MATLAB path before running the script from Python. You can do this by using the addpath function in MATLAB. For example, if the directory containing the necessary function or variable is located at C:\path\to\directory, you can add it to the MATLAB path as follows:
addpath('C:\path\to\directory')
You can add this line of code to your MATLAB script before the line that uses the 'config_io' function or variable.
Alternatively, you could implement the functionality of 'config_io' in Python using available libraries or by writing your own code. This might be a better solution if you need to run the script on multiple platforms or if you want to avoid dependencies on MATLAB.
More Answers (0)
See Also
Categories
Find more on Call MATLAB from Python in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!