I am trying to call a python script from Matlab (2022b update 3) function compiled into a docker container on WSL2. I have tried a couple methods, but no luck. For example, I tried using the following build procedure below (where the python3 executable and the python file are in ./AdditionalFiles). Calling the python fails:
Python commands require a supported version of CPython.
Error in testCompPy
MATLAB:Python:PythonUnavailable
I tried including the pyenv("Version","/python3") in the matlab script and that errors as well.
MATLAB:Pyversion:InvalidPath
even though including exist("/python3") in the compiled function shows that is there.
By adding a disp(pwd) to the Matlab code I was able to see that pwd is "/", which is why I copy the additional files there. Futhermore, apt-get commands don't seem to work but I think that might be something to do with running in a docker container inside wsl.
res = compiler.build.standaloneApplication('testCompPy.m','TreatInputsAsNumeric', false);
opts = compiler.package.DockerOptions(res,'ImageName','testcompy-standalone-app','AdditionalInstructions',...
["COPY ./AdditionalFiles/ /"]);
compiler.package.docker(res, 'Options', opts);
The resulting DockerFile looks like
FROM matlabruntime/r2022b/release/update3/300000000000000000
COPY ./applicationFilesForMATLABCompiler /usr/bin/mlrtapp
RUN chmod -R a+rX /usr/bin/mlrtapp/*
COPY ./AdditionalFiles/ /
RUN useradd -ms /bin/bash appuser
ENTRYPOINT ["/usr/bin/mlrtapp/testCompPy"]
Any advice or ideas would be appreciated. Also, any insight into what capabilities from Ubuntu are in the matlabruntime docker image would also be helpful.
For reference, the m-file being compiled is
function testCompPy(varargin)
pyenv("Version",'/python3')
in = {'Jones','Johnson','James'};
names = py.mymod.search(N);