Python from an external interpreter

You can use Python for Maya with an external interpreter other than mayapy.However, you will need to set up the environment manually, and you will need to ensure that you are using the same version of Python as is shipped with Maya. See the appropriate Open Source Component page for information on the version of Python that is shipped with your version of Maya.

To set up the environment for a Python interpreter, add the path to the Maya site-packages directory to your PYTHONPATH environment variable.

On Windows you can either set PYTHONPATH in your environment variables accessible from the Control Panel, or you can set it from the command prompt:

set PYTHONPATH=%PYTHONPATH%;<path_to_site_packages>

On Linux and macOS, you can add to PYTHONPATH to your ~/.bashrc file or you can set it on the command line:

export PYTHONPATH=$PYTHONPATH:<path_to_site_packages>

You can also add the path to site-packages from within your interpreter by calling sys.path.append('<path_to_site_packages>').

The paths to site-packages are listed below relative C:\Program Files\Autodesk\Maya<VersionNumber>\ on Windows, /usr/Autodesk/Maya<VersionNumber> on Linux, and /Applications/Autodesk/maya<VersionNumber>/Maya.app/Contents/ on macOS:

Platform Path to site-packages
Windows <PythonVersion>\Lib\site-packages
Linux lib/<PythonVersion>/site-packages
macOS Frameworks/Python.framework/Versions/Current/lib/<PythonVersion>/site-packages/

On Linux, add $MAYA_LOCATION/lib/<PythonVersion> to the LD_LIBRARY_PATH directory.

Make sure that $MAYA_LOCATION has been set to point to the Maya installation directory, /usr/Autodesk/Maya<VersionNumber>, before using it in LD_LIBRARY_PATH. If MAYA_LOCATION is not set, use the full path to the Maya installation directory.