- 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 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
MathWorks Support Team
el 5 de En. de 2026 a las 0:00
Respondida: MathWorks Support Team
el 5 de En. de 2026 a las 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?
Respuesta aceptada
MathWorks Support Team
el 5 de En. de 2026 a las 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 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Python Client Programming en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!