Python code in Matlab standalone app

조회 수: 37 (최근 30일)
Imdat
Imdat 2025년 9월 4일 13:18
댓글: Kevin Holly 2025년 9월 5일 15:57
Using the "Python Code task in the Live Editor" I created an *mlx file that runs my Python correctly in Matlab. Using this file in the App designer of Matlab also works fine untill I compile a standalone app. Then it doesn't work anymore: The app can be launched but it doesn't work. Not on my computer and also not on other computers without Matlab/Python (without any error).
Anything that I can do to get it working?

답변 (1개)

Kevin Holly
Kevin Holly 2025년 9월 4일 20:32
You can save your python code in a script and call the .py file from MATLAB using pyrunfile. When you go to compile the app make sure the .py file is included in the package.
  댓글 수: 2
Imdat
Imdat 2025년 9월 5일 12:48
Hi Kevin,
I tried exactly what you advised:
Get the Python script file and make it available in the Matlab folder and run it in Matlab using pyrunfile. In the development environment it runs fine like before but whenever I create the standalone app (including the Python file attached) it doesn't work anymore. The App starts but doesn't execute the script in it. This even doesn't work on my PC where I developed the scripts and the App.
Any other things that I can check/try?
Kevin Holly
Kevin Holly 2025년 9월 5일 15:57
Imdat,
Perhaps, the app isn't finding the script. I have attached an example app and Python script (saved as txt file) that I was able to compile. My first attempt, the Python script was not found after packaging. I am willing to jump on a call if that would help. Free feel to reach out to me at kevinh@mathworks.com.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Call Python from MATLAB에 대해 자세히 알아보기

제품


릴리스

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by