Python Error: ModuleNotFoundError during execution in a Web App

조회 수: 3 (최근 30일)
Christian Idzik
Christian Idzik 2022년 7월 27일
댓글: Christian Idzik 2023년 10월 13일
Hi everyone,
I created a simple App in AppDesigner on Linux where I call a python function output = py.MyModule.myFunction()
In this py script I also import the opcua library. This works without problems.
Next, I complied it to a matlab web app (ctf file) and ran it on the same machine within the Matlab Web App Server.
I also added the MyModule.py File in Files required for your app to run in the Web App Compiler.
Moreover, I added the current folder to the python system path during the startup function and tried to load the opcua lib.
if isdeployed
[filepath,~,~] = fileparts(mfilename('fullpath'));
insert(py.sys.path, int64(0), filepath);
...
py.importlib.import_module('opcua');
end
But at the start comes directly an error:
I have extra output the properties of the Python environment and compared it with the one in Matlab. It shows the same properties:
Now, unfortunately, I do not know what to do. Does anyone have an idea what the problem is?
Thanks in advance!

채택된 답변

Chaitanya
Chaitanya 2023년 10월 11일
Hello Christian,
I understand that you have built an app in Linux that uses python modules. However, while compiling it to a CTF file for deploying as a web app, you are receiving errors that python module.
At this point I am assuming that you have referred to the below given MATLAB Answer to configure the MATLAB Web App Server to use Python.
You may consider the following MATLAB Answers that can help you to resolve the issue.
  1. https://in.mathworks.com/matlabcentral/answers/1763835-how-to-configure-matlab-web-app-server-to-use-python
  2. https://in.mathworks.com/support/search.html/answers/2007282-unable-to-resolve-name-error-when-calling-python-from-matlab-web-app-server.html
I hope this helps!

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Python Client Programming에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by