I have this python script:
from collections import OrderedDict
from docopt import docopt
from zephir.__version__ import __version__
from skimage.transform import resize
from zephir.utils.utils import *
from zephir.utils.io import *
from getters import * # This is a script located in the same folder as the script itself.
Which I call using the following MATLAB code:
[fullfile(app.script_dir, sprintf('recommend_frames%s', app.script_ext)),sprintf(' --channel=1 --dataset="%s" --nx=%.f --ny=%.f --nz=%.f --nc=%.f --nt=%.f',app.video_path, app.video_info.nx, app.video_info.ny, app.video_info.nz, app.video_info.nc, app.video_info.nt)]
t_ref = pyrunfile([fullfile(app.script_dir, sprintf('recommend_frames%s', app.script_ext)),sprintf(' --channel=1 --dataset="%s" --nx=%.f --ny=%.f --nz=%.f --nc=%.f --nt=%.f',app.video_path, app.video_info.nx, app.video_info.ny, app.video_info.nz, app.video_info.nc, app.video_info.nt)],'t_ref');
Which produces this output:
'C:\Users\sep27\Documents\GitHub\NeuroPAL_ID\+Wrapper\recommend_frames.py --channel=1 --dataset="D:\demo\20221014_m6.h5" --nx=512 --ny=500 --nz=23 --nc=3 --nt=4981'
Error using <string>><module>
Python Error: ModuleNotFoundError: No module named 'getters'
However, the script executes just fine when run through a shell.
This is not the only issue I'm running into with MATLAB's python wrapper -- I also have a separate script, main.py, which executes fine in a shell, but yields a syntax error when run using pyrunfile:
py_cmd = sprintf('%s %s %s %s', fullfile(app.script_dir, sprintf('converter%s', app.script_ext)), fullfile(pwd, 'cache.mat'), fullfile(pwd, 'meta_cache.mat'), app.video_path)
Output:
'C:\Users\sep27\Documents\GitHub\NeuroPAL_ID\+Wrapper\converter.py C:\Users\sep27\Documents\GitHub\NeuroPAL_ID\cache.mat C:\Users\sep27\Documents\GitHub\NeuroPAL_ID\meta_cache.mat D:\demo\20221014_m6.h5'
Error using matlab.apps.AppBase>@(source,event)executeCallback(ams,app,callback,requiresEventData,event)
Python Error: SyntaxError: invalid syntax (<string>, line 84)
I've checked pyenv and ensured that the correct executable is selected. Here's the output for reference:
PythonEnvironment with properties:
Executable: "C:\Users\sep27\AppData\Local\Programs\Python\Python310\python.exe"
Library: "C:\Users\sep27\AppData\Local\Programs\Python\Python310\python310.dll"
Home: "C:\Users\sep27\AppData\Local\Programs\Python\Python310"
ExecutionMode: OutOfProcess
ProcessName: "MATLABPyHost"