Launching Maya Standalone hangs on startup

I’m trying to run Maya Standalone on MacOS from a Terminal using /Applications/Autodesk/maya2018/Maya.app/Contents/bin/mayapy and the command

./mayapy /Users/bradley.newman/ArtSource/ArtPipeline/Maya/Scripts/export.py

which runs this code in export.py:

import maya.standalone

try:
    print("Try to initialize maya standalone...")
    maya.standalone.initialize(name='python')
except Exception as e:
    print("Exception trying to initialize Maya standalone. Error:" + str(e) + ", Message: " + e.message, e.args)
    pass
else:
    print("No exception when intializing Maya standalone.")

import maya.cmds as cmds

filepath = "/Users/bradley.newman/ArtSource/Characters/Animation/AvatarMale/Test/Test.ma"

try:
    print("Trying to open file.")
    cmds.file(filepath, o=True)
except Exception as e:
    print("Exception trying to open file. Error:" + str(e) + ", Message: " + e.message, e.args)
    pass
else:
    print("No exception when opening file.")

The process seems to hang during initiaization of Maya Standalone, and never gets around to opening the file. Anyone know what might be causing it to hang? Here is the Terminal output:

C02C40L3MD6W:bin bradley.newman$ ./mayapy     /Users/bradley.newman/ArtSource/ArtPipeline/Maya/Scripts/export.py
Try to initialize maya standalone...
pymel.core : INFO : Updating pymel with pre-loaded plugins: renderSetup
Error: file: /Applications/Autodesk/maya2018/plug-ins/xgen/scripts/xgmToolRegistration.mel line 58: Cannot find procedure "xgmToolManagerRegisterTool".
Warning: file: /Applications/Autodesk/maya2018/plug-ins/xgen/scripts/igInitialize.mel line 78: Couldn't source xgmToolRegistration.mel
Warning: file: /Users/bradley.newman/Library/Preferences/Autodesk/maya/2018/prefs/filePathEditorRegistryPrefs.mel line 4: filePathEditor: Attribute 'aiImage.filename' is invalid or is not designated 'usedAsFilename'.
Warning: file: /Users/bradley.newman/Library/Preferences/Autodesk/maya/2018/prefs/filePathEditorRegistryPrefs.mel line 5: filePathEditor: Attribute 'aiStandIn.dso' is invalid or is not designated 'usedAsFilename'.
Warning: file: /Users/bradley.newman/Library/Preferences/Autodesk/maya/2018/prefs/filePathEditorRegistryPrefs.mel line 6: filePathEditor: Attribute 'aiVolume.filename' is invalid or is not designated 'usedAsFilename'.
AbcExport v1.0 using Alembic 1.5.8 (built Dec 24 2015 17:46:02)
Initialized VP2.0 renderer {
  Version : 2016.11.35.12. Feature Level 5.
  Adapter : ATI Radeon Pro 5500M OpenGL Engine
  Vendor ID: 4098. Device ID : 0x7340
  Driver : 4.1 ATI-3.4.19.
  API : OpenGL V.4.1.
  Max texture size : 16384 * 16384.
  Max tex coords : 32
  Shader versions supported (Vertex: 5, Geometry: 5, Pixel 5).
  Shader compiler profile : (Best card profile)
  Active stereo support available : 0
  GPU Memory Limit : 8176 MB.
  CPU Memory Limit: 31129.6 MB.
###############################################################################
Begin attempted read of a script fragment XML file.
Attempting to read fragment XML code from: mayaUIDrawPass.xml
Errors loading XML:
-------------------------------------------------------------------------------
Could not find file: mayaUIDrawPass.xml
-------------------------------------------------------------------------------
End attempted read of fragment XML.
###############################################################################
}
OpenCL evaluator is attempting to initialize OpenCL.
Detected 1 OpenCL Platforms: 
 0: Apple. Apple. OpenCL 1.2 (Nov  9 2019 04:32:50).
 Supported extensions: cl_APPLE_SetMemObjectDestructor cl_APPLE_ContextLoggingFunctions cl_APPLE_clut cl_APPLE_query_kernel_names cl_APPLE_gl_sharing cl_khr_gl_event
OpenCL evaluator choosing OpenCL platform Apple.
10152
Choosing OpenCL Device ATI Radeon Pro 5500M Compute Engine.  Device Type: GPU  Device is available.

###############################################################################
Begin attempted read of a shade fragment XML file.
Attempting to read fragment XML code from: channelsBase.xml
Errors loading XML:
-------------------------------------------------------------------------------
Could not find file: channelsBase.xml
-------------------------------------------------------------------------------
End attempted read of fragment XML.
###############################################################################
###############################################################################
Begin attempted read of a fragment graph XML file.
Attempting to read fragment XML code from: channels.xml
Errors loading XML:
-------------------------------------------------------------------------------
Could not find file: channels.xml
-------------------------------------------------------------------------------
End attempted read of fragment XML.
###############################################################################
###############################################################################
Begin attempted read of a shade fragment XML file.
Attempting to read fragment XML code from: combineMayaTextureOutput.xml
Errors loading XML:
-------------------------------------------------------------------------------
Could not find file: combineMayaTextureOutput.xml
-------------------------------------------------------------------------------
End attempted read of fragment XML.
###############################################################################
###############################################################################
Begin attempted read of a shade fragment XML file.
Attempting to read fragment XML code from: floatPassThrough.xml
Errors loading XML:
-------------------------------------------------------------------------------
Could not find file: floatPassThrough.xml
-------------------------------------------------------------------------------
End attempted read of fragment XML.
###############################################################################
###############################################################################
Begin attempted read of a shade fragment XML file.
Attempting to read fragment XML code from: floatComposite.xml
Errors loading XML:
-------------------------------------------------------------------------------
Could not find file: floatComposite.xml
-------------------------------------------------------------------------------
End attempted read of fragment XML.
###############################################################################
###############################################################################
Begin attempted read of a shade fragment XML file.
Attempting to read fragment XML code from: colorCompositeBase.xml
Errors loading XML:
-------------------------------------------------------------------------------
Could not find file: colorCompositeBase.xml
-------------------------------------------------------------------------------
End attempted read of fragment XML.
###############################################################################
###############################################################################
Begin attempted read of a fragment graph XML file.
Attempting to read fragment XML code from: colorComposite.xml
Errors loading XML:
-------------------------------------------------------------------------------
Could not find file: colorComposite.xml
-------------------------------------------------------------------------------
End attempted read of fragment XML.
###############################################################################
###############################################################################
Begin attempted read of a shade fragment XML file.
Attempting to read fragment XML code from: combineMayaTextureOutput.xml
Errors loading XML:
-------------------------------------------------------------------------------
Could not find file: combineMayaTextureOutput.xml
-------------------------------------------------------------------------------
End attempted read of fragment XML.
###############################################################################
###############################################################################
Begin attempted read of a shade fragment XML file.
Attempting to read fragment XML code from: boolPassThrough.xml
Errors loading XML:
-------------------------------------------------------------------------------
Could not find file: boolPassThrough.xml
-------------------------------------------------------------------------------
End attempted read of fragment XML.
###############################################################################
###############################################################################
Begin attempted read of a shade fragment XML file.
Attempting to read fragment XML code from: floatCondition.xml
Errors loading XML:
-------------------------------------------------------------------------------
Could not find file: floatCondition.xml
-------------------------------------------------------------------------------
End attempted read of fragment XML.
###############################################################################
###############################################################################
Begin attempted read of a shade fragment XML file.
Attempting to read fragment XML code from: colorConditionBase.xml
Errors loading XML:
-------------------------------------------------------------------------------
Could not find file: colorConditionBase.xml
-------------------------------------------------------------------------------
End attempted read of fragment XML.
###############################################################################
###############################################################################
Begin attempted read of a fragment graph XML file.
Attempting to read fragment XML code from: colorCondition.xml
Errors loading XML:
-------------------------------------------------------------------------------
Could not find file: colorCondition.xml
-------------------------------------------------------------------------------
End attempted read of fragment XML.
###############################################################################
###############################################################################
Begin attempted read of a shade fragment XML file.
Attempting to read fragment XML code from: combineMayaTextureOutput.xml
Errors loading XML:
-------------------------------------------------------------------------------
Could not find file: combineMayaTextureOutput.xml
-------------------------------------------------------------------------------
End attempted read of fragment XML.
###############################################################################
###############################################################################
Begin attempted read of a shade fragment XML file.
Attempting to read fragment XML code from: floatConstant.xml
Errors loading XML:
-------------------------------------------------------------------------------
Could not find file: floatConstant.xml
-------------------------------------------------------------------------------
End attempted read of fragment XML.
###############################################################################
###############################################################################
Begin attempted read of a shade fragment XML file.
Attempting to read fragment XML code from: colorConstantBase.xml
Errors loading XML:
-------------------------------------------------------------------------------
Could not find file: colorConstantBase.xml
-------------------------------------------------------------------------------
End attempted read of fragment XML.
###############################################################################
###############################################################################
Begin attempted read of a fragment graph XML file.
Attempting to read fragment XML code from: colorConstant.xml
Errors loading XML:
-------------------------------------------------------------------------------
Could not find file: colorConstant.xml
-------------------------------------------------------------------------------
End attempted read of fragment XML.
###############################################################################
###############################################################################
Begin attempted read of a shade fragment XML file.
Attempting to read fragment XML code from: combineMayaTextureOutput.xml
Errors loading XML:
-------------------------------------------------------------------------------
Could not find file: combineMayaTextureOutput.xml
-------------------------------------------------------------------------------
End attempted read of fragment XML.
###############################################################################
###############################################################################
Begin attempted read of a shade fragment XML file.
Attempting to read fragment XML code from: floatPassThrough.xml
Errors loading XML:
-------------------------------------------------------------------------------
Could not find file: floatPassThrough.xml
-------------------------------------------------------------------------------
End attempted read of fragment XML.
###############################################################################
###############################################################################
Begin attempted read of a shade fragment XML file.
Attempting to read fragment XML code from: colorConditionBase.xml
Errors loading XML:
-------------------------------------------------------------------------------
Could not find file: colorConditionBase.xml
-------------------------------------------------------------------------------
End attempted read of fragment XML.
###############################################################################
###############################################################################
Begin attempted read of a shade fragment XML file.
Attempting to read fragment XML code from: premultiply.xml
Errors loading XML:
-------------------------------------------------------------------------------
Could not find file: premultiply.xml
-------------------------------------------------------------------------------
End attempted read of fragment XML.
###############################################################################
###############################################################################
Begin attempted read of a shade fragment XML file.
Attempting to read fragment XML code from: unpremultiply.xml
Errors loading XML:
-------------------------------------------------------------------------------
Could not find file: unpremultiply.xml
-------------------------------------------------------------------------------
End attempted read of fragment XML.
###############################################################################
###############################################################################
Begin attempted read of a shade fragment XML file.
Attempting to read fragment XML code from: floatCorrect.xml
Errors loading XML:
-------------------------------------------------------------------------------
Could not find file: floatCorrect.xml
-------------------------------------------------------------------------------
End attempted read of fragment XML.
###############################################################################
###############################################################################
Begin attempted read of a shade fragment XML file.
Attempting to read fragment XML code from: colorCorrectBase.xml
Errors loading XML:
-------------------------------------------------------------------------------
Could not find file: colorCorrectBase.xml
-------------------------------------------------------------------------------
End attempted read of fragment XML.
###############################################################################
###############################################################################
Begin attempted read of a fragment graph XML file.
Attempting to read fragment XML code from: colorCorrect.xml
Errors loading XML:
-------------------------------------------------------------------------------
Could not find file: colorCorrect.xml
-------------------------------------------------------------------------------
End attempted read of fragment XML.
###############################################################################
###############################################################################
Begin attempted read of a shade fragment XML file.
Attempting to read fragment XML code from: floatLogic.xml
Errors loading XML:
-------------------------------------------------------------------------------
Could not find file: floatLogic.xml
-------------------------------------------------------------------------------
End attempted read of fragment XML.
###############################################################################
###############################################################################
Begin attempted read of a shade fragment XML file.
Attempting to read fragment XML code from: colorLogic.xml
Errors loading XML:
-------------------------------------------------------------------------------
Could not find file: colorLogic.xml
-------------------------------------------------------------------------------
End attempted read of fragment XML.
###############################################################################
###############################################################################
Begin attempted read of a shade fragment XML file.
Attempting to read fragment XML code from: combineMayaTextureOutput.xml
Errors loading XML:
-------------------------------------------------------------------------------
Could not find file: combineMayaTextureOutput.xml
-------------------------------------------------------------------------------
End attempted read of fragment XML.
###############################################################################
###############################################################################
Begin attempted read of a shade fragment XML file.
Attempting to read fragment XML code from: floatPassThrough.xml
Errors loading XML:
-------------------------------------------------------------------------------
Could not find file: floatPassThrough.xml
-------------------------------------------------------------------------------
End attempted read of fragment XML.
###############################################################################
###############################################################################
Begin attempted read of a shade fragment XML file.
Attempting to read fragment XML code from: floatCondition.xml
Errors loading XML:
-------------------------------------------------------------------------------
Could not find file: floatCondition.xml
-------------------------------------------------------------------------------
End attempted read of fragment XML.
###############################################################################
###############################################################################
Begin attempted read of a shade fragment XML file.
Attempting to read fragment XML code from: floatSubtract.xml
Errors loading XML:
-------------------------------------------------------------------------------
Could not find file: floatSubtract.xml
-------------------------------------------------------------------------------
End attempted read of fragment XML.
###############################################################################
###############################################################################
Begin attempted read of a shade fragment XML file.
Attempting to read fragment XML code from: colorConditionBase.xml
Errors loading XML:
-------------------------------------------------------------------------------
Could not find file: colorConditionBase.xml
-------------------------------------------------------------------------------
End attempted read of fragment XML.
###############################################################################
###############################################################################
Begin attempted read of a shade fragment XML file.
Attempting to read fragment XML code from: floatMask.xml
Errors loading XML:
-------------------------------------------------------------------------------
Could not find file: floatMask.xml
-------------------------------------------------------------------------------
End attempted read of fragment XML.
###############################################################################
###############################################################################
Begin attempted read of a shade fragment XML file.
Attempting to read fragment XML code from: colorMaskBase.xml
Errors loading XML:
-------------------------------------------------------------------------------
Could not find file: colorMaskBase.xml
-------------------------------------------------------------------------------
End attempted read of fragment XML.
###############################################################################
###############################################################################
Begin attempted read of a fragment graph XML file.
Attempting to read fragment XML code from: colorMask.xml
Errors loading XML:
-------------------------------------------------------------------------------
Could not find file: colorMask.xml
-------------------------------------------------------------------------------
End attempted read of fragment XML.
###############################################################################
###############################################################################
Begin attempted read of a shade fragment XML file.
Attempting to read fragment XML code from: combineMayaTextureOutput.xml
Errors loading XML:
-------------------------------------------------------------------------------
Could not find file: combineMayaTextureOutput.xml
-------------------------------------------------------------------------------
End attempted read of fragment XML.
###############################################################################
###############################################################################
Begin attempted read of a shade fragment XML file.
Attempting to read fragment XML code from: floatMath.xml
Errors loading XML:
-------------------------------------------------------------------------------
Could not find file: floatMath.xml
-------------------------------------------------------------------------------
End attempted read of fragment XML.
###############################################################################
###############################################################################
Begin attempted read of a shade fragment XML file.
Attempting to read fragment XML code from: colorMathBase.xml
Errors loading XML:
-------------------------------------------------------------------------------
Could not find file: colorMathBase.xml
-------------------------------------------------------------------------------
End attempted read of fragment XML.
###############################################################################
###############################################################################
Begin attempted read of a fragment graph XML file.
Attempting to read fragment XML code from: colorMath.xml
Errors loading XML:
-------------------------------------------------------------------------------
Could not find file: colorMath.xml
-------------------------------------------------------------------------------
End attempted read of fragment XML.
###############################################################################
###############################################################################
Begin attempted read of a shade fragment XML file.
Attempting to read fragment XML code from: premultiply.xml
Errors loading XML:
-------------------------------------------------------------------------------
Could not find file: premultiply.xml
-------------------------------------------------------------------------------
End attempted read of fragment XML.
###############################################################################
###############################################################################
Begin attempted read of a shade fragment XML file.
Attempting to read fragment XML code from: unpremultiply.xml
Errors loading XML:
-------------------------------------------------------------------------------
Could not find file: unpremultiply.xml
-------------------------------------------------------------------------------
End attempted read of fragment XML.
###############################################################################
###############################################################################
Begin attempted read of a shade fragment XML file.
Attempting to read fragment XML code from: combineMayaTextureOutput.xml
Errors loading XML:
-------------------------------------------------------------------------------
Could not find file: combineMayaTextureOutput.xml
-------------------------------------------------------------------------------
End attempted read of fragment XML.
###############################################################################
###############################################################################
Begin attempted read of a shade fragment XML file.
Attempting to read fragment XML code from: simplexNoiseBase.xml
Errors loading XML:
-------------------------------------------------------------------------------
Could not find file: simplexNoiseBase.xml
-------------------------------------------------------------------------------
End attempted read of fragment XML.
###############################################################################
###############################################################################
Begin attempted read of a fragment graph XML file.
Attempting to read fragment XML code from: simplexNoise.xml
Errors loading XML:
-------------------------------------------------------------------------------
Could not find file: simplexNoise.xml
-------------------------------------------------------------------------------
End attempted read of fragment XML.
###############################################################################
Warning: file: /Applications/Autodesk/maya2018/Maya.app/Contents/bin/../scripts/startup/autoLoadPlugin.mel line 35: Loading plug-in "lookdevKit" has resulted in changes to the scene that may need to be saved.
Warning: line 1: filePathEditor: Attribute 'aiStandIn.dso' and label 'Standin' have been saved already.
Warning: line 1: filePathEditor: Attribute 'aiVolume.filename' and label 'VDB' have been saved already.
00:00:00   503MB WARNING |  unable to load dynamic library /Applications/solidangle/mtoa/2018/procedurals/bifrost_procedurals.dylib: 
00:00:00   504MB WARNING | [mtoa] [bifrost_shaders] [node bifrostFoamMaterial] Assigning temporary node id 1138176 to associated Maya type name bifrostFoamMaterial.
00:00:00   504MB WARNING | [mtoa] [bifrost_shaders] [node bifrostAeroMaterial] Assigning temporary node id 1138177 to associated Maya type name bifrostAeroMaterial.
Warning: line 1: filePathEditor: Attribute 'aiImage.filename' and label 'Image' have been saved already.
Successfully imported python module 'arnold'
Successfully imported python module 'mtoa'
Maya 2018 importing module pymel 1.0.10 (/Applications/Autodesk/maya2018/Maya.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python2.7/site-packages/pymel/__init__.py)
Successfully registered renderer 'arnold'
AbcImport v1.0 using Alembic 1.5.8 (built Dec 24 2015 17:46:02)

Running userSetup.py =========================================
OpenPort(4434)
Trying to open command port :4434
Successully opened port :4434
Finished running userSetup.py ==================================

Can’t say I recognize those errors, but it looks like it is at least getting to your userSetup.py file.

My recommendation would be to disable all your plugins from the GUI, and possibly disable your userSetup.py file with the MAYA_SKIP_USERSETUP_PY environment variable.

Then try slowly adding them back on and see where it breaks?

Thanks for the tip. I commented out my userSetup.py, and it opened the file. The userSetup.py contained:

import pymel.core as pm
import maya.cmds as cmds
import utility as utility

print("")
print("Running userSetup.py =========================================")

# Open port to connect to PyCharm > MayaCharm plugin
utility.OpenPort(4434)

print("Finished running userSetup.py ==================================")
print("")

However, I’m now getting the following errors when opening the test file. Not sure why I would get these errors, the test file is just an empty new file I saved from the Maya GUI…

Try to initialize maya standalone...
No exception when intializing Maya standalone.
Trying to open file.
File read in  0.0078 seconds.
File read in  0.0078 seconds.
(u"Exception trying to open file. 

Error:file: /Users/bradley.newman/Test/Test.ma line 26: 
The camera 'perspShape' has no '.ai_translator' attribute.\n
file: /Users/bradley.newman/Test/Test.ma line 26: setAttr: No object matches name: .ai_translator\n
file: /Users/bradley.newman/Test/Test.ma line 42: The camera 'topShape' has no '.ai_translator' attribute.\n
file: /Users/bradley.newman/Test/Test.ma line 42: setAttr: No object matches name: .ai_translator\n
file: /Users/bradley.newman/Test/Test.ma line 59: The camera 'frontShape' has no '.ai_translator' attribute.\n
file: /Users/bradley.newman/Test/Test.ma line 59: setAttr: No object matches name: .ai_translator\n
file: /Users/bradley.newman/Test/Test.ma line 76: The camera 'sideShape' has no '.ai_translator' attribute.\n
file: /Users/bradley.newman/Test/Test.ma line 76: setAttr: No object matches name: .ai_translator\nError reading file.\n
Error reading file.\n

Perhaps I need to load the MtoA Arnold plugin?

I’m attempting to load Arnold with:

cmds.loadPlugin("MtoA")

And now getting this error when opening the file:

Plug-in, "MtoA", was not found on MAYA_PLUG_IN_PATH.

After googling a few errors, I got the file to open.

Not sure why loading Arnold directly didn’t work, but loading all plugins like so seems to have resolved the errors:

cmds.loadPlugin(allPlugins=True)

Then, I received an error about “Unsaved changes.” in the file, so I had to force the file to open like so:

cmds.file(filepath, open=True, force=True)

After that, the file opened.

Here is the full code:

import maya.standalone
maya.standalone.initialize(name='python')
import maya.cmds as cmds

cmds.loadPlugin(allPlugins=True)

filepath = "/Users/bradley.newman/Test/Test.ma"
cmds.file(filepath, open=True, force=True)

Try that where its lower case. Pretty sure its case sensitive (because Maya is weird like that)

Question about that, is that a blocking operation? Or does it just make sure the port is open?