フィルターのクリア

Ubuntu & Python - Matlab Engine Error when call eng.load_system()

3 ビュー (過去 30 日間)
André
André 2023 年 7 月 29 日
回答済み: Dinesh 2023 年 8 月 17 日
Hello,
I have a problem when running the eng.load_system() function from Python. When doing so, the following error message occurs and the file is dropped in the attachment:
EngineError Traceback (most recent call last)
Cell In [5], line 1
----> 1 eng.load_system(modelname)
File ~/KI-Diss/KI-Diss/lib/python3.10/site-packages/matlab/engine/matlabengine.py:71, in MatlabFunc.__call__(self, *args, **kwargs)
68 return FutureResult(self._engine(), future, nargs, _stdout, _stderr, feval=True)
69 else:
70 return FutureResult(self._engine(), future, nargs, _stdout,
---> 71 _stderr, feval=True).result()
File ~/KI-Diss/KI-Diss/lib/python3.10/site-packages/matlab/engine/futureresult.py:67, in FutureResult.result(self, timeout)
64 if timeout < 0:
65 raise TypeError(pythonengine.getMessage('TimeoutCannotBeNegative'))
---> 67 return self.__future.result(timeout)
File ~/KI-Diss/KI-Diss/lib/python3.10/site-packages/matlab/engine/fevalfuture.py:82, in FevalFuture.result(self, timeout)
79 if not result_ready:
80 raise TimeoutError(pythonengine.getMessage('MatlabFunctionTimeout'))
---> 82 self._result = pythonengine.getFEvalResult(self._future,self._nargout, None, out=self._out, err=self._err)
83 self._retrieved = True
84 return self._result
EngineError: MATLAB function cannot be evaluated
I have already set the paths QT_PLUGIN_PATH (/usr/lib/x86_64-linux-gnu/qt5/plugins) and LD_LIBRARY_PATH (usr/local/MATLAB/R2022b/sys/os/glnxa64:/usr/local/MATLAB/R2022b/bin/glnxa64), but both without success. My Python instance is running in a virtual environment (venv). I have successfully tested all functions directly in Matlab, as well as the Python coupling on a Windows machine. I have also already tested the call to load_system() in a .m file, but the same error occurs. Does anyone please have a hint what else it could be?
  1 件のコメント
André
André 2023 年 7 月 29 日
The following command was the solution for me:
export QT_QPA_PLATFORM = offscreen

サインインしてコメントする。

回答 (1 件)

Dinesh
Dinesh 2023 年 8 月 17 日
Hi Andre!
I understand that you are encountering an error while trying to load a model using the MATLAB Engine for Python. The error is related to the Qt package, which is commonly used for creating graphical user interfaces. It seems that the system you are working on is attempting to use certain features of the Qt package and is trying to draw on the screen.
On Linux, the QT_QPA_PLATFORM environment variable is set to 'xcb' by default. This environment variable forces Qt applications to use the 'xcb' QPA platform plugin and if Qt does not have this plugin, then the application just does not start and instead throws an error 'This application failed to start because it could not find or load the Qt platform plugin and reinstalling application might solve the issue'.
To address the problem, you can implement the following approaches.
  • You can try installing the relevant modules specified in the Qt for X11 requirements using the following command.
sudo apt-get install '^libxcb.*-dev' libx11-xcb-dev libglu1-mesa-dev libxrender-dev libxi-dev libxkbcommon-devlibxkbcommon-x11-dev
  • You can set the QT_QPA_PLATFORM environment variable to 'offscreen'. This will run your program in headless mode, meaning fit will not require a screen.This can be helpful if you do not need any graphical output and just want to run the program in a non-interactive mode.
Hope this helps.
Regards
Dinesh Gatla

カテゴリ

Help Center および File ExchangeCall Python from MATLAB についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by