- Install a supported version of Python on the server machine. Ensure that the account used to run MPS has access to this installation.
- Identify the path to the Python executable on the server (e.g. C:\Users\username\AppData\Local\Programs\Python\Python311\python.exe).
- Add the following code to the beginning of the MATLAB function you want to deploy, using the identified path: This will configure this code to use the correct Python installation when running on MATLAB Production Server. This should be added to all deployed functions that use Python.if isdeployedpyenv(Version="C:\Users\username\AppData\Local\Programs\Python\Python311\python.exe");end
How do I set up MATLAB Production Server (MPS) to use Python?
9 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
MathWorks Support Team
am 5 Jan. 2026 um 0:00
Beantwortet: MathWorks Support Team
am 5 Jan. 2026 um 20:44
I have a MATLAB function that calls Python, which I would like to deploy to MATLAB Production Server (MPS). For MATLAB Desktop, I can follow these instructions to configure the system to use Python.
How can I do this for code running on MATLAB Production Server?
Akzeptierte Antwort
MathWorks Support Team
am 5 Jan. 2026 um 0:00
Note that this answer is about setting up Python for use in deployed code (e.g. using py. or pyrun) on MATLAB Production Server. For information on setting up the Python client for MATLAB Production Server, see this documentation.
To properly configure the Python environment to be used when running deployed code on MATLAB Production Server:
If you encounter unexpected behavior or errors during execution of Python code on MPS, see Why does my MATLAB Production Server request sometimes fail for CTFs that use Python?
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Python Client Programming finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!