Use python functions in packages created with MATLAB Compiler SDK

6 vues (au cours des 30 derniers jours)
Christopher Wunder
Christopher Wunder le 7 Avr 2022
Commenté : Ayush le 16 Oct 2023
Hi,
I'm using the Matlab Compiler SDK to create a python package and integrate it in a python application.
Now the package itself, that is the matlab code, also uses python functions from a module.
In the packaged library the py. command is not recognized and thus the module function names are not resolved.
I get a warning: Warning: Ability to call Python libraries from MATLAB is not available with MATLAB Compiler SDK for Python
Is there any possibility to include python functions in matlab code and then build the package OR do I need to remove all py. calls from my matlab code and outsource this functionality somehow?
  1 commentaire
Ayush
Ayush le 16 Oct 2023
Hi Christopher,
I understand that you want to use python functions in the MATLAB code and build a package around it.
The warning you received indicates that the ability to package Python libraries from MATLAB is not available with "MATLAB Compiler SDK" for Python. This means that you won't be able to directly use Python functions from within your MATLAB code when building the package. Please refer to the below documentation to know more about “Python Package Integration” in “MATLAB Compiler SDK”:
Some possible workarounds for this issue are the same as mentioned by you:
Remove py. calls from MATLAB code: Modify your MATLAB code to remove any dependencies on Python functions. This would entail rewriting the affected code in MATLAB or finding alternative MATLAB functions to achieve the same functionality.
Outsource the functionality: If the functionality provided by the Python module is critical and cannot be easily replicated in MATLAB, you can consider creating a separate Python package or module that encapsulates the required functionality. You can then call this Python package from your Python application, independent of the MATLAB Compiler SDK.
Hope it helps,
Regards,
Ayush Misra

Connectez-vous pour commenter.

Réponses (0)

Catégories

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

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by