Main Content

mwpython

Start a Python session using a MATLAB Compiler SDK Python package on Mac OS X

Description

example

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.

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

example

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

Input Arguments

collapse all

Python arguments, specified as a comma-separated list.

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

  • -nojvm — disable the Java® Virtual Machine, which is enabled by default. This can help improve the MATLAB Runtime performance.

  • -nodisplay — on Linux®, run the MATLAB Runtime without display functionality.

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