Use python functions in packages created with MATLAB Compiler SDK

4 views (last 30 days)
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 Comment
Ayush
Ayush on 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

Sign in to comment.

Answers (0)

Categories

Find more on MATLAB Compiler SDK in Help Center and File Exchange

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!