If you get API errors and Error: Failed to open python module 'arnold' and a crash/segmentation fault when you try to load the MtoA plugin in mayapy, it's probably because mayapy cannot find the MtoA and Arnold Python modules.

If you compare sys.path in mayapy with the sys.path in Maya, you'll see that in mayapy, the MtoA scripts folder is missing. For example, here's the mayapy output on my Windows machine:

>>> import sys
>>> import maya.standalone
>>> maya.standalone.initialize()
>>> for p in sys.path:
...     print p
...
C:\Program Files\Autodesk\Maya2014\bin\python27.zip
C:\Program Files\Autodesk\Maya2014\Python\DLLs
C:\Program Files\Autodesk\Maya2014\Python\lib
C:\Program Files\Autodesk\Maya2014\Python\lib\plat-win
C:\Program Files\Autodesk\Maya2014\Python\lib\lib-tk
C:\Program Files\Autodesk\Maya2014\bin
C:\Program Files\Autodesk\Maya2014\Python
C:\Program Files\Autodesk\Maya2014\Python\lib\site-packages
C:\Program Files\Autodesk\Maya2014\bin\python27.zip\lib-tk
C:/Users/stephen/Documents/maya/2014-x64/prefs/scripts
C:/Users/stephen/Documents/maya/2014-x64/scripts
C:/Users/stephen/Documents/maya/scripts

If I run the same Python in Maya (before I load MtoA), I see a lot more paths, including the MtoA scripts folder, in sys.path:

import sys
for p in sys.path:
    print p
C:\Program Files\Autodesk\maya2014\bin
C:\Users\SOLIDANGLE
C:\Program Files\Autodesk1\mentalrayForMaya2014\scripts\AETemplates
C:\Program Files\Autodesk1\mentalrayForMaya2014\scripts\mentalray
C:\Program Files\Autodesk1\mentalrayForMaya2014\scripts\unsupported
C:\Program Files\Autodesk1\mentalrayForMaya2014\scripts
C:\solidangle\mtoadeploy\MtoA\scripts
C:\Users\SOLIDANGLE\Downloads\Yeti-v1.3.5_Maya2014-windows64\Yeti-v1.3.5_Maya2014-windows64\scripts
C:\Program Files\JoeAlter\shaveHaircut\maya2014\scripts
C:\Program Files\Autodesk\maya2014\substance\scripts
C:\Program Files\Autodesk\maya2014\plug-ins\xgen\scripts\cafm
C:\Program Files\Autodesk\maya2014\plug-ins\xgen\scripts\xgenm
C:\Program Files\Autodesk\maya2014\plug-ins\xgen\scripts\xgenm\ui
C:\Program Files\Autodesk\maya2014\plug-ins\xgen\scripts\xgenm\xmaya
C:\Program Files\Autodesk\maya2014\plug-ins\xgen\scripts\xgenm\ui\brushes
C:\Program Files\Autodesk\maya2014\plug-ins\xgen\scripts\xgenm\ui\dialogs
C:\Program Files\Autodesk\maya2014\plug-ins\xgen\scripts\xgenm\ui\fxmodules
C:\Program Files\Autodesk\maya2014\plug-ins\xgen\scripts\xgenm\ui\tabs
C:\Program Files\Autodesk\maya2014\plug-ins\xgen\scripts\xgenm\ui\util
C:\Program Files\Autodesk\maya2014\plug-ins\xgen\scripts\xgenm\ui\widgets
C:\Program Files\Autodesk\maya2014\plug-ins\xgen\scripts
C:\Program Files\Autodesk\maya2014\bin\python27.zip
C:\Program Files\Autodesk\maya2014\Python\DLLs
C:\Program Files\Autodesk\maya2014\Python\lib
C:\Program Files\Autodesk\maya2014\Python\lib\plat-win
C:\Program Files\Autodesk\maya2014\Python\lib\lib-tk
C:\Program Files\Autodesk\maya2014\bin
C:\Program Files\Autodesk\maya2014\Python
C:\Program Files\Autodesk\maya2014\Python\lib\site-packages
C:\Program Files\Autodesk\maya2014\bin\python27.zip\lib-tk
C:/Users/SOLIDANGLE/Documents/maya/2014-x64/prefs/scripts
C:/Users/SOLIDANGLE/Documents/maya/2014-x64/scripts
C:/Users/SOLIDANGLE/Documents/maya/scripts

 

To add the MtoA script folder to the sys.path so you can load MtoA, you can either set PYTHONPATH before you start mayapy, or append the MtoA scripts folder to sys.path in your script, like this:

>>> import sys
>>> sys.path.append( 'C:\solidangle\mtoadeploy\2014\scripts' )
>>> import maya.standalone
>>> maya.standalone.initialize()
>>> import maya.cmds as cmds
>>> cmds.loadPlugin('mtoa')
>>> cmds.file(new=True, force=True)
u'untitled'
>>> cmds.file('C:/users/stephen/documents/maya/projects/default/scenes/example.mb', o=True)
File read in 0 seconds.
u'C:/users/stephen/documents/maya/projects/default/scenes/example.mb'
>>>

 

For reference, here's the full error output from mayapy (on Windows) when the MtoA scripts folder is missing from sys.path:

>>> import sys
>>> import maya.standalone
>>> maya.standalone.initialize()
>>> import maya.cmds as cmds
>>> cmds.loadPlugin('mtoa')
API error detected in plugins\mtoa\extension\PxMayaNode.cpp at line 218
: (kFailure): Unexpected Internal Failure
API error detected in plugins\mtoa\extension\PxMayaNode.cpp at line 218
: (kFailure): Unexpected Internal Failure
API error detected in plugins\mtoa\extension\PxMayaNode.cpp at line 218
: (kFailure): Unexpected Internal Failure
API error detected in plugins\mtoa\extension\PxMayaNode.cpp at line 218
: (kFailure): Unexpected Internal Failure
00:00:00 145MB WARNING | [mtoa] Extension xgen(xgen) requires Maya plugin xgen Toolkit, registering will be deferred until plugin is loaded.
00:00:00 147MB WARNING | [mtoa] [shave] [node ShaveHair] Assigning temporary node id 1138176 to associated Maya type name shaveHair.
00:00:00 147MB ERROR | [mtoa] Error opening c:/solidangle/mtoadeploy/shaders/bin.
API error detected in plugins\mtoa\extension\ExtensionsManager.cpp at line 567
: (kFailure): Unexpected Internal Failure
API error detected in plugins\mtoa\extension\ExtensionsManager.cpp at line 567
: (kFailure): Unexpected Internal Failure
API error detected in plugins\mtoa\extension\ExtensionsManager.cpp at line 567
: (kFailure): Unexpected Internal Failure
API error detected in plugins\mtoa\Main.cpp at line 772
: (kFailure): Unexpected Internal Failure
00:00:00 149MB ERROR | Failed to import python module 'arnold'
Error: No module named mtoa.lightFilters
# Traceback (most recent call last):
# File "<maya console>", line 1, in <module>
# ImportError: No module named mtoa.lightFilters
Error: No module named mtoa.lightFilters
# Traceback (most recent call last):
# File "<maya console>", line 1, in <module>
# ImportError: No module named mtoa.lightFilters
Error: No module named mtoa.lightFilters
# Traceback (most recent call last):
# File "<maya console>", line 1, in <module>
# ImportError: No module named mtoa.lightFilters
Error: No module named mtoa.lightFilters
# Traceback (most recent call last):
# File "<maya console>", line 1, in <module>
# ImportError: No module named mtoa.lightFilters
Error: No module named mtoa.api.extensions
# Traceback (most recent call last):
# File "<maya console>", line 1, in <module>
# ImportError: No module named mtoa.api.extensions
Error: No module named mtoa.api.extensions
# Traceback (most recent call last):
# File "<maya console>", line 1, in <module>
# ImportError: No module named mtoa.api.extensions
Error: No module named mtoa.api.extensions
# Traceback (most recent call last):
# File "<maya console>", line 1, in <module>
# ImportError: No module named mtoa.api.extensions
Error: No module named arnold
# Traceback (most recent call last):
# File "<maya console>", line 1, in <module>
# ImportError: No module named arnold
Error: Failed to import python module 'arnold'
Error: initializePlugin function failed (mtoa)
Link to this page