Effacer les filtres
Effacer les filtres

Exporting Matlab code as Python package: Coolprop dependency error

42 vues (au cours des 30 derniers jours)
VS
VS le 9 Juil 2024 à 14:44
Modifié(e) : Walter Roberson le 19 Juil 2024 à 18:39
I have a Matlab code that accesses python wrapper for CoolProp and uses CoolProp.CoolProp.PropsSI function calls to get state properties in the form of py.CoolProp.CoolProp.PropsSI(...).
For example:
function T = test(p)
T= py.CoolProp.CoolProp.PropsSI('T','P',p,'Q',0,"Nitrogen");
end
If you run it from Matlab, everything works.
Following the steps in Create Python Application Using Library Compiler App I exported the Matlab functions as a python package. It is explicitly stated that the dependencies are recognized and added automatically. However, I encountered the following error when a function is called (see Package MATLAB Function and Deploy to Python Application) in Python:
import matlab_package as mtl
handle = mtl.initialize()
T = handle.test(100000)
MatlabRuntimeError: An error occurred when evaluating the result from a function. Details: File ....m, line ..., in ...\mcrCache23.2\...\...\....m, line ..., in run_model Unable to resolve the name 'py.CoolProp.CoolProp.PropsSI'.
I am not sure how I need to export it so that the dependency works. Any help?
UPDATE:
I narrowed down the issue to the InProcess operation of MatlabRuntime. Is there a way to invoke it Out-Of-Process? I have included
pyenv(ExecutionMode="OutOfProcess")
into the packaged matlab function, but it doesn't seem help it.

Réponses (1)

Oliver Jaehrig
Oliver Jaehrig le 10 Juil 2024 à 14:08
Modifié(e) : Walter Roberson le 19 Juil 2024 à 18:39
  1 commentaire
VS
VS le 19 Juil 2024 à 15:19
Modifié(e) : VS le 19 Juil 2024 à 16:32
sadly it didn't help. I believe the problem lies in the execution mode of the Matlab runtime. It runs InProcess, and I cannot find a way to invoke it Out-Of-Process

Connectez-vous pour commenter.

Catégories

En savoir plus sur Python Package Integration dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by