Using CoolProp in MATLAB
31 次查看(过去 30 天)
显示 更早的评论
Hi guys, I am currently using MATLAB 2023a and I have added CoolProp to MATLAB. But now I am trying to make a standalone app so others with no MATLAB on their computer can use it. But when I share my app their computer doesn't recognise CoolProp formulas. Is there any way I can make this work ? Thank you.
0 个评论
回答(2 个)
Sai Teja G
2023-8-28
Hi Eray,
I understand that you want to run your app in other computers where MATLAB is not installed.
It is indeed possible, and you can achieve it by following the link provided below to ensure its functionality.
Hope it helps!
0 个评论
hsin-yu
2024-2-16
I also encountered the same problem. I compiled the thermal property calculation APP on a computer with MATLAB, and packaged the APP and sent it to a user who did not have MATLAB. The user had python installed, but the python environment status was detected as not loaded. Therefore it cannot be calculated.
Is this because the APP cannot execute the command window ?
If the APP has this limitation, how to solve it?
------------------<my code>---------------------------------------------------------------
% Prompt the user for the Python installation directory and provide examples
default_python_dir = 'C:\Users\user\AppData\Local\Programs\Python\Python310\python.exe';
python_dir_cell = inputdlg('Please enter the directory where Python executable is located:', 'Python Directory', [1, 100], {default_python_dir});
python_dir = char(python_dir_cell);
% If the user cancels input, return
if isempty(python_dir)
return;
end
try
% Try to execute pyenv
pe = pyenv("Version", python_dir);
% Display Python environment information
disp(pe);
% Convert Python environment information to a string
pe_str = evalc('disp(pe)');
% Display Python environment information string
msgbox(pe_str, 'Python Environment');
% Determine whether to import CoolProp based on whether Python status is loaded
if strcmp(pe.Status, 'Loaded')
% Try to install CoolProp
[v, e] = pyversion;
cmd = [e, ' -m pip install --user -U CoolProp'];
system(cmd);
pause(0.1);
% Display success message box
msgbox('Connected successfully.', 'Success');
else
% Show error message box
msgbox('Python is not loaded. Please make sure Python version supports MATLAB.', 'Error');
end
catch ME
% If an error occurs, display an error message box
errorMessage = ME.message;
msgbox(errorMessage, 'Error', 'error');
end
1 个评论
hsin-yu
2024-2-16
编辑:hsin-yu
2024-2-16
Success! Use Windows CMD to execute the coolprop connection command!
--------------------------------------------------------------------------
cmd_path = 'C:\WINDOWS\system32\cmd.exe';
command = ['"', cmd_path, '" /c "', python_dir, '" -m pip install CoolProp'];
% python_dir is your python.exe path.
--------------------------------------------------------------------------
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Introduction to Installation and Licensing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!