how to convert a python script with matlab function called to exe?
显示 更早的评论
I write a function in MATLAB and use the "Library Compiler" to convert it to "Python Packages", then i write a python script to do some other things and call the function in the Python Packages. Both the function and the script run perfectly in MATLAB PythonCMD or windowsPowerShell.
But i need to get a standalone application running on windows platform. I use pyinstaller to convert it into exe, but i can not run the exe.It says:
PS C:\Users\86732\Desktop\program\dist> .\easytest.exe
Traceback (most recent call last):
File "program\easytest.py", line 2, in <module>
File "program\DrawPkg\__init__.py", line 301, in initialize
File "program\DrawPkg\__init__.py", line 249, in initialize_package
File "D:\MATLAB2017b\toolbox\compiler_sdk\pysdk_py\matlab_pysdk\runtime\deployablepackage.py", line 33, in initialize
mcr_handle = self.__cppext_handle.startMatlabRuntimeInstance(self.__ctf_path)
SystemError: Cannot find CTF archive 'AppData\Local\Temp\_MEI45282\DrawPkg\DrawPkg.ctf'.
[13564] Failed to execute script easytest
I have tried to put 'DrawPkg' whole folder to the same folder of easytest.py, still not work
my MATLAB function:
function DrawCurveBoard(tmp_Rho1, tmp_Height1)
blabla..(no output)
and my Python Script follows: (runs fine in the form of script)
import DrawPkg
my = DrawPkg.initialize()
Rho1 = float(input(' first Rho1:'))
Height1 = float(input(' first Height1:'))
my.DrawCurveBoard(Rho1, Height1, nargout=0)
pack to exe:(It says successfully)
pyinstaller -F -c ./easytest.py
Does anyone know where the problem is? I tried many ways but still cannot get the .exe work :(
采纳的回答
更多回答(1 个)
ChangYuan Liu
2021-3-16
0 个投票
Thank you for the answer! Your answer helped me a lot!
类别
在 帮助中心 和 File Exchange 中查找有关 Python Package Integration 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!