How to use Python on Webapp Server running on Windows?

조회 수: 11 (최근 30일)
Pranav
Pranav 2023년 9월 4일
편집: Rushikesh 2024년 10월 8일
I have created predict.py and added to .ctf, In startup I have used following code
if isdeployed
pyenv(Version="C:\Users\MatlabWebAppVM\AppData\Local\Programs\Python\Python39");
[filepath,~,~] = fileparts(mfilename('fullpath'));
insert(py.sys.path, int64(0), filepath);
end
Getting this error while running on server

답변 (1개)

Rushikesh
Rushikesh 2024년 10월 8일
편집: Rushikesh 2024년 10월 8일
Hello,
I understand that you're trying to execute Python code within a MATLAB Web App by setting the 'pyenv' version in the 'startupFcn'. However, you're encountering a long loop that ends with a "Something went wrong" error. This error typically occurs when the MATLAB Web App Server is unable to access the Python installation directory.
The MATLAB Web App Worker account, named “MwWebAppWorkerR2024a” (replace with the appropriate version for your MATLAB installation), needs permission to access your Python executable directory.
Here's how you can set the necessary permissions on Windows:
  1. Open File Explorer and navigate to the Python installation directory, for example, C:\Users\username\AppData\Local\Programs\Python\Python39.
  2. Right-click on the Python folder and select "Properties."
  3. Go to the "Security" tab.
  4. Click "Edit," then "Add."
  5. Click "Advanced," and under "From this location," select your computer's hostname (you can find your hostname by typing hostname in the Command Prompt).
  6. Click "Find Now," locate, and select "MwWebAppWorkerR2024a" (or the appropriate account for your MATLAB version).
  7. Grant the necessary permissions to the Web App Server account to allow it to run your web application.
I've attached a screenshot of the “Properties > Security > Edit > Add” window for clarity. For more detailed instructions on configuring the MATLAB Web App Server to use Python, you can refer to the below MATLAB Answer.
Hope this helps you.

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by