Main Content

mwpython

Start a Python session using a MATLAB Compiler SDK Python package on macOS

Description

mwpython [-verbose] [py_args] [-mlstartup opt[,opt]] Starts an interactive Python® session.

example

mwpython [-verbose] [py_args] [-mlstartup opt[,opt]] python_scriptname Starts a Python session that executes a Python script.

example

mwpython [-verbose] [py_args] [-mlstartup opt[,opt]] -c cmd Starts a Python session that executes a Python command.

mwpython [-verbose] [py_args] [-mlstartup opt[,opt]] -m mod Starts a Python session that executes a Python module.

example

Input Arguments

collapse all

Python arguments, specified as a comma-separated list.

MATLAB Runtime startup options, specified as a comma-separated list.

MATLAB Runtime Startup OptionDescription
-nojvmDisable the Java® Virtual Machine (JVM®), which is enabled by default. This can help improve the MATLAB Runtime performance.
-nodisplayOn Linux®, open the MATLAB Runtime without display functionality.
'-logfile,filename'Write information about the MATLAB Runtime startup to a logfile.
'-startmsg,message'Specify message to be displayed when the MATLAB Runtime begins initialization.
'-completemsg,message'Specify message to be displayed when the MATLAB Runtime completes initialization.

Python script to execute, specified as a character array with a .py extension.

Python command to execute, specified as a character array.

Python module to execute, specified as a character array.

Note

If you want to use a specific version of Python, set the PYTHONHOME environment variable on your machine to point to the parent of the directory that contains the Python interpreter for the desired Python installation prior to invoking mwpython.

Alternatively, to use a virtual Python environment, see the MATLAB Answers™ article Python virtual environments with Python Interface.

Note

If you have a Python virtual environment, and it is activated, the VIRTUAL_ENV environment variable will be set to the location of your virtual environment. mwpython will check this variable and use it to find the interpreter. If you have a Python virtual environment, but it is not activated, or if you don't have a Python virtual environment, you can set the VIRTUAL_ENV to point to any virtual environment or interpreter.

Examples

Execute a Python Script in Verbose Mode

mwpython -verbose myfile.py

Execute a Python Module with Arguments

mwpython -m mymod arg1 arg2

Version History

Introduced in R2015b