How to run a matlab exe which contains python commands from another python code?

1 次查看(过去 30 天)
I have a Matlab code which calls some python modules. I made an exe from this Matlab code (let's call it pipeMe.exe) now I'm trying to run pipeMe.exe from another python code in another machine of course but apparently, it can't set the python version executable path from the second machine, thus it gives me this error:
Undefined variable "py" or class "py.sys.path".
Is there any way that I can set the pyversion executable from outside of Matlab while I run pipeMe.exe ? Or is there any possibility to set the pyversion executable path to a path that is accessible from both machines, and I just have to set it at the beginning of my pipeMe matlab code?
Thanks in advance for your help.

回答(1 个)

Yuanjie Su
Yuanjie Su 2019-9-20
[name,dir,index]=uigetfile({'*.exe'},'choose python.exe file');
if index==1
py_path=[dir name];
pyversion(py_path);
end
py_path is your python interpreter file path.(the file is called python.exe)

类别

Help CenterFile Exchange 中查找有关 Call Python from MATLAB 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by