Standalone GUI application crashes with error and GUI python package closes immediately, does not stay open

조회 수: 2 (최근 30일)
I created a standalone executable version of a GUI but it opens the GUI for an instance and crashes with "not enough input arguments" error, when run from a folder that does not contain the related GUI .m/.fig files, for e.g. while running directly from the desktop. The line of error is from the main GUI m-file shown below. The application runs as expected when run from the folder containing all the accompanying files.
gui_mainfcn(gui_State, varargin{:});
I was also trying to create a python package of the same GUI, but a similar experience with the GUI not staying open. Simply shows the GUI instantaneously but closes immediately with no particular error message.

채택된 답변

Harsh
Harsh 2018년 5월 9일
It appears that the GUI was made using App Designer / Guide and relies on dependent files being present in the current directory. Note that a compiled application behaves more consistently if it avoids accessing or changing the current directory. A more reliable way is to base all file locations on a known root i.e. ctfroot for deployed applications. For example:
load('c:/Work/MATLAB/data.mat')% creates dependency on file structure
% Instead use
[pathstr,name]=fileparts(which('data.mat'));
load(name);
Detailed examples on managing path for deployed applications can be found here: https://blogs.mathworks.com/loren/2008/08/11/path-management-in-deployed-applications/
To further narrow down the exact point of error, on a Windows Machine before compiling, Under Additional runtime settings -> uncheck "Do not display the Windows Command Shell' and check 'Create log file'.
The Python error is also likely connected to the path issues of the standalone application.
  댓글 수: 1
jchaliss
jchaliss 2018년 5월 12일
Thanks Harsh! The standalone application problem was indeed related to the usage of path and trying to load/save mat files to a certain path. Also, the log file option helped narrow down the error.
For the python, the problem still remains. I'm trying to build a python lib of the same GUI so that it can be used cross platform and so that thinking I need not build the same app on a Linux system. Is path handling different for python libs? Is there a way to generate a error report like the standalone exe for the python version as well?

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Python Package Integration에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by