Can't import maya file in mayapy.exe

Hello guys,

I am trying to import a simple (contains only geometry) Maya file into a new scene with Maya Standalone and it is crushing:

MAYAPY = "C:/PROGRA~1/Autodesk/Maya2020/bin/mayapy.exe"

script = 'C:/build_maya_scene.py'
cmd = '{0} -t {1}'.format(MAYAPY, script)
os.system(cmd)

Here is the build_maya_scene.py script

import pymel.core as pm

print 'importing...'
mb = 'C:/_TESTER.mb'
pm.importFile(mb, returnNewNodes=True, defaultNamespace=True)
print 'imported' 

This is the error log:

C:\Python27\python.exe C:/run_build.py

Error: file: C:/PROGRA~1/Autodesk/Maya2020/scripts/startup/initEvaluationManager.mel line 48: Plug-in, "cacheEvaluator", was not found on MAYA_PLUG_IN_PATH.
Warning: file: C:/PROGRA~1/Autodesk/Maya2020/scripts/startup/initialStartup.mel line 179: Y-axis is already the Up-axis
Error: file: C:/PROGRA~1/Autodesk/Maya2020/scripts/startup/autoLoadPlugin.mel line 35: Plug-in, "modelingToolkit", was not found on MAYA_PLUG_IN_PATH.
Error: file: C:/PROGRA~1/Autodesk/Maya2020/scripts/startup/autoLoadPlugin.mel line 35: Plug-in, "invertShape", was not found on MAYA_PLUG_IN_PATH.
Error: file: C:/PROGRA~1/Autodesk/Maya2020/scripts/startup/autoLoadPlugin.mel line 35: Plug-in, "mayaHIK", was not found on MAYA_PLUG_IN_PATH.
Error: file: C:/PROGRA~1/Autodesk/Maya2020/scripts/startup/autoLoadPlugin.mel line 35: Plug-in, "GamePipeline", was not found on MAYA_PLUG_IN_PATH.
Error: file: C:/PROGRA~1/Autodesk/Maya2020/scripts/startup/autoLoadPlugin.mel line 35: Plug-in, "curveWarp", was not found on MAYA_PLUG_IN_PATH.
Error: file: C:/PROGRA~1/Autodesk/Maya2020/scripts/startup/autoLoadPlugin.mel line 35: Plug-in, "tiffFloatReader", was not found on MAYA_PLUG_IN_PATH.
Error: file: C:/PROGRA~1/Autodesk/Maya2020/scripts/startup/autoLoadPlugin.mel line 35: Plug-in, "poseInterpolator", was not found on MAYA_PLUG_IN_PATH.
Error: file: C:/PROGRA~1/Autodesk/Maya2020/scripts/startup/autoLoadPlugin.mel line 35: Plug-in, "ATFPlugin", was not found on MAYA_PLUG_IN_PATH.
Error: file: C:/PROGRA~1/Autodesk/Maya2020/scripts/startup/autoLoadPlugin.mel line 35: Plug-in, "hairPhysicalShader", was not found on MAYA_PLUG_IN_PATH.
Error: file: C:/PROGRA~1/Autodesk/Maya2020/scripts/startup/autoLoadPlugin.mel line 35: Plug-in, "ikSpringSolver", was not found on MAYA_PLUG_IN_PATH.
Error: file: C:/PROGRA~1/Autodesk/Maya2020/scripts/startup/autoLoadPlugin.mel line 35: Plug-in, "ik2Bsolver", was not found on MAYA_PLUG_IN_PATH.
Error: file: C:/PROGRA~1/Autodesk/Maya2020/scripts/startup/autoLoadPlugin.mel line 35: Plug-in, "xgenToolkit", was not found on MAYA_PLUG_IN_PATH.
Error: file: C:/PROGRA~1/Autodesk/Maya2020/scripts/startup/autoLoadPlugin.mel line 35: Plug-in, "AbcExport", was not found on MAYA_PLUG_IN_PATH.
[2020/Dec/16|18:58:59] V-Ray: V-Ray Next for Maya, update 2.2 version 4.30.02 from Apr 24 2020, 14:37:35
[2020/Dec/16|18:58:59] V-Ray: V-Ray core version is 4.30.03
[VMAYA PT] Loaded and initialized C:\Program Files\Autodesk\Maya2020\vray/shaders/ptbercon_special.dll
[VMAYA PT] Loaded and initialized C:\Program Files\Autodesk\Maya2020\vray/shaders/ptuvwgen_bercon.dll
Initializing V-Ray for Maya

[2020/Dec/16|18:59:01] V-Ray: Loading plugins from "C:\Program Files\Autodesk\Maya2020\vray/vrayplugins/vray_*.dll"
[2020/Dec/16|18:59:01] V-Ray: 83 plugin(s) loaded successfully
[2020/Dec/16|18:59:01] V-Ray: Finished loading plugins.
Warning: V-Ray: Could not get the renderer
Warning: V-Ray VolumeGrid: Loading shaders failed - no <*.txt> files in .
V-Ray VolumeGrid: loading C:\Program Files\Autodesk\Maya2020\vray/scripts/VRayVolumeGridInit.mel...
Warning: file: C:\Users\kko8\Documents\maya\2020\prefs\filePathEditorRegistryPrefs.mel line 4: filePathEditor: Attribute 'aiImage.filename' is invalid or is not designated 'usedAsFilename'.
Warning: file: C:\Users\kko8\Documents\maya\2020\prefs\filePathEditorRegistryPrefs.mel line 5: filePathEditor: Attribute 'aiPhotometricLight.aiFilename' is invalid or is not designated 'usedAsFilename'.
Warning: file: C:\Users\kko8\Documents\maya\2020\prefs\filePathEditorRegistryPrefs.mel line 6: filePathEditor: Attribute 'aiStandIn.dso' is invalid or is not designated 'usedAsFilename'.
Warning: file: C:\Users\kko8\Documents\maya\2020\prefs\filePathEditorRegistryPrefs.mel line 7: filePathEditor: Attribute 'aiVolume.filename' is invalid or is not designated 'usedAsFilename'.
V-Ray VolumeGrid: OK.
Error: Register failed for vrayAOVChildSelector
[2020/Dec/16|18:59:02] V-Ray: Registered dynamic node vrayMultiProjection (id: 1115335/0x001104C7)
[2020/Dec/16|18:59:02] V-Ray: Registered dynamic node VRayCurvature (id: 1115347/0x001104D3)
[2020/Dec/16|18:59:02] V-Ray: Registered dynamic node VRayTriplanar (id: 1115362/0x001104E2)
[2020/Dec/16|18:59:02] V-Ray: Registered dynamic node VRayPointParticleMtl (id: 1115353/0x001104D9)
[2020/Dec/16|18:59:02] V-Ray: Registered dynamic node VRayStochasticFlakesMtl (id: 1115359/0x001104DF)
[2020/Dec/16|18:59:02] V-Ray: Registered dynamic node VRayAlSurface (id: 1115350/0x001104D6)
[2020/Dec/16|18:59:02] V-Ray: Registered dynamic node VRayHairNextMtl (id: 1115320/0x001104B8)
[2020/Dec/16|18:59:02] V-Ray: Registered dynamic node VRayBerconNoise (id: 1115370/0x001104EA)
info:  MDL SDK 2018.1, build 307800.1800, 09 Aug 2018, nt-x86-64
info:  Loaded library "C:\PROGRA~1\Autodesk\Maya2020\bin\libvrayfreeimage.dll".
Error: file: C:/PROGRA~1/Autodesk/Maya2020/scripts/startup/autoLoadPlugin.mel line 35: Plug-in, "VectorRender", was not found on MAYA_PLUG_IN_PATH.
Error: file: C:/PROGRA~1/Autodesk/Maya2020/scripts/startup/autoLoadPlugin.mel line 35: Plug-in, "gameFbxExporter", was not found on MAYA_PLUG_IN_PATH.
Error: file: C:/PROGRA~1/Autodesk/Maya2020/scripts/startup/autoLoadPlugin.mel line 35: Plug-in, "OpenEXRLoader", was not found on MAYA_PLUG_IN_PATH.
Error: file: C:/PROGRA~1/Autodesk/Maya2020/scripts/startup/autoLoadPlugin.mel line 35: Plug-in, "lookdevKit", was not found on MAYA_PLUG_IN_PATH.
Error: file: C:/PROGRA~1/Autodesk/Maya2020/scripts/startup/autoLoadPlugin.mel line 35: Plug-in, "Unfold3D", was not found on MAYA_PLUG_IN_PATH.
Error: file: C:/PROGRA~1/Autodesk/Maya2020/scripts/startup/autoLoadPlugin.mel line 35: Plug-in, "mayaCharacterization", was not found on MAYA_PLUG_IN_PATH.
Error: file: C:/PROGRA~1/Autodesk/Maya2020/scripts/startup/autoLoadPlugin.mel line 35: Plug-in, "Type", was not found on MAYA_PLUG_IN_PATH.
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.
Initialized VP2.0 renderer {
  Version : 2016.11.53.12. Feature Level 5.
  Adapter : GRID T4-8Q/PCI/SSE2
  Vendor ID: 4318. Device ID : 1029
  Driver : .
  API : OpenGL V.4.6.
  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 : 8192 MB.
  CPU Memory Limit: 93387.8 MB.
  MultiDraw consolidation: enabled
}
OpenCL evaluator is attempting to initialize OpenCL.
Detected 1 OpenCL Platforms: 
 0: NVIDIA Corporation. NVIDIA CUDA. OpenCL 1.2 CUDA 10.2.108.
 Supported extensions: cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_fp64 cl_khr_byte_addressable_store cl_khr_icd cl_khr_gl_sharing cl_nv_compiler_options cl_nv_device_attribute_query cl_nv_pragma_unroll cl_nv_d3d10_sharing cl_khr_d3d10_sharing cl_nv_d3d11_sharing cl_nv_copy_opts cl_khr_gl_event cl_nv_create_buffer cl_khr_int64_base_atomics cl_khr_int64_extended_atomics cl_kernel_attribute_nv 
OpenCL evaluator choosing OpenCL platform NVIDIA Corporation.
OpenCL evaluator is unable to find a GPU device that can share VBOs with OpenGL.
Warning: line 1: filePathEditor: Attribute 'aiImage.filename' and label 'Image' have been saved already.
Warning: line 1: filePathEditor: Attribute 'aiPhotometricLight.aiFilename' and label 'IES' have been saved already.
Successfully imported python module 'arnold'
Successfully imported python module 'mtoa'
C:\PROGRA~1\Autodesk\Maya2020\Python\lib\site-packages\maya\app\stereo\stereoCameraUtil.py: inconsistent use of tabs and spaces in indentation
Error: Register failed for arnoldAOVChildSelector
Warning: };
Warning: "C:/PROGRA~1/Autodesk/Maya2020/scripts/others/imageFormats.mel" line 65.2 : Global variable is already initialized; this occurrence is ignored.
Successfully registered renderer 'arnold'
Warning: file: C:/PROGRA~1/Autodesk/Maya2020/scripts/startup/autoLoadPlugin.mel line 35: Loading plug-in "mtoa" has resulted in changes to the scene that may need to be saved.
Error: file: C:/PROGRA~1/Autodesk/Maya2020/scripts/startup/autoLoadPlugin.mel line 35: Plug-in, "meshReorder", was not found on MAYA_PLUG_IN_PATH.
Error: file: C:/PROGRA~1/Autodesk/Maya2020/scripts/startup/autoLoadPlugin.mel line 35: Plug-in, "modelingToolkit", was not found on MAYA_PLUG_IN_PATH.
Error: file: C:/PROGRA~1/Autodesk/Maya2020/scripts/startup/autoLoadPlugin.mel line 35: Plug-in, "rotateHelper", was not found on MAYA_PLUG_IN_PATH.
Error: file: C:/PROGRA~1/Autodesk/Maya2020/scripts/startup/autoLoadPlugin.mel line 35: Plug-in, "MayaMuscle", was not found on MAYA_PLUG_IN_PATH.
Error: file: C:/PROGRA~1/Autodesk/Maya2020/scripts/startup/autoLoadPlugin.mel line 35: Plug-in, "dx11Shader", was not found on MAYA_PLUG_IN_PATH.
Error: file: C:/PROGRA~1/Autodesk/Maya2020/scripts/startup/autoLoadPlugin.mel line 35: Plug-in, "matrixNodes", was not found on MAYA_PLUG_IN_PATH.
Error: file: C:/PROGRA~1/Autodesk/Maya2020/scripts/startup/autoLoadPlugin.mel line 35: Plug-in, "AbcImport", was not found on MAYA_PLUG_IN_PATH.
Error: file: C:/PROGRA~1/Autodesk/Maya2020/scripts/startup/autoLoadPlugin.mel line 35: Plug-in, "autoLoader", was not found on MAYA_PLUG_IN_PATH.
Error: file: C:/PROGRA~1/Autodesk/Maya2020/scripts/startup/autoLoadPlugin.mel line 35: Plug-in, "sceneAssembly", was not found on MAYA_PLUG_IN_PATH.
Error: file: C:/PROGRA~1/Autodesk/Maya2020/scripts/startup/autoLoadPlugin.mel line 35: Plug-in, "gpuCache", was not found on MAYA_PLUG_IN_PATH.
Error: file: C:/PROGRA~1/Autodesk/Maya2020/scripts/startup/autoLoadPlugin.mel line 35: Plug-in, "OneClick", was not found on MAYA_PLUG_IN_PATH.
Error: file: C:/PROGRA~1/Autodesk/Maya2020/scripts/startup/autoLoadPlugin.mel line 49: Plug-in, "OneClick", was not found on MAYA_PLUG_IN_PATH.
Error: file: C:/PROGRA~1/Autodesk/Maya2020/scripts/startup/autoLoadPlugin.mel line 35: Plug-in, "shaderFXPlugin", was not found on MAYA_PLUG_IN_PATH.
Error: file: C:/PROGRA~1/Autodesk/Maya2020/scripts/startup/autoLoadPlugin.mel line 35: Plug-in, "objExport", was not found on MAYA_PLUG_IN_PATH.
Error: file: C:/PROGRA~1/Autodesk/Maya2020/scripts/startup/autoLoadPlugin.mel line 35: Plug-in, "ArubaTessellator", was not found on MAYA_PLUG_IN_PATH.
Error: file: C:/PROGRA~1/Autodesk/Maya2020/scripts/startup/autoLoadPlugin.mel line 35: Plug-in, "quatNodes", was not found on MAYA_PLUG_IN_PATH.
importing...
Error: file: C:/PROGRA~1/Autodesk/Maya2020/scripts/startup/autoLoadPlugin.mel line 35: Plug-in, "fbxmaya", was not found on MAYA_PLUG_IN_PATH.
Stack trace:
  Shared.dll!TattrCompatCmd::loadTables
  Translators.dll!TmayaBinaryAccessor::readHeader
  Translators.dll!TmayaBinaryAccessor::iffVLeafMethod2
  Foundation.dll!TiffParserCallback::iffLeafMethod
  Foundation.dll!TiffFile8::parseKernel
  Foundation.dll!TiffFile8::parseKernel
  Foundation.dll!TiffFile8::parseKernel
  Foundation.dll!TiffFile::parse
  Translators.dll!TmayaBinaryAccessor::internalRead
  Translators.dll!TmayaBinaryAccessor::internalRead
  Translators.dll!TmayaBinaryAccessor::reader
  Shared.dll!TfileTranslator::read
  Shared.dll!TglobalTranslator::doReadFile
  Shared.dll!TfileUtil::readFile
  Shared.dll!TsceneOperator::saveScene
  Shared.dll!TsceneOperator::saveScene
  Shared.dll!TfileCmd::handleFileImportFlag
  Shared.dll!TfileCmd::handleFlags
  Shared.dll!TfileCmd::handleFlags
  Shared.dll!TfileCmd::doCommand
  CommandEngine.dll!TpythonInterpreter::dispatchMayaCommand
  python27.dll!PyCFunction_Call
  python27.dll!PyEval_GetFuncDesc
  python27.dll!PyEval_EvalFrameEx
  python27.dll!PyEval_EvalCodeEx
  python27.dll!PyFunction_SetClosure
  python27.dll!PyObject_Call
  python27.dll!PyEval_GetFuncDesc
  python27.dll!PyEval_EvalFrameEx
  python27.dll!PyEval_EvalCodeEx
  python27.dll!PyEval_GetFuncDesc
  python27.dll!PyEval_GetFuncDesc
  python27.dll!PyEval_EvalFrameEx
  python27.dll!PyEval_EvalCodeEx
  python27.dll!PyRun_FileExFlags
  python27.dll!PyRun_FileExFlags
  python27.dll!PyRun_SimpleFileExFlags
  python27.dll!PyRun_AnyFileExFlags
  python27.dll!Py_Main
  mayapy.exe!<7FF601652A3C>
00007FFDC084F600[WARNING] V-Ray for Maya may not have been uninitialized properly!

Process finished with exit code 0

This huge list of errors doesn’t break the script until I try to import a file. E.g. I can create a new scene, add some primitives, build materials, etc and save a file successfully. But importing another Maya file does not work. Errors after Stack trace: represents the issue probably.

What can I try to fix this?

You calling this to initialize headless?

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

Then do your standard imports:

import maya.cmds as cmds
...

Tried, it does not make a difference, so I delete this part of code.

Ok, I found a workaround.

Create a bat file C:/run_py.bat:

"C:\Program Files\Autodesk\Maya2020\bin\mayapy.exe" C:/run_build.py

Run bat file:

subprocess.call(['C:/run_py.bat'])

Then imports does not crash Mayapy.

Actually, one interesting thing…

If you use this path to mayapy:
C:/PROGRA~1/Autodesk/Maya2020/bin/mayapy.exe
it is crashes, and its working with this path:
"C:\Program Files\Autodesk\Maya2020\bin\mayapy.exe"

Which is super weird…

@kiryha Hmm… interesting - the only thing I notice (other than the symlink) is your slashes are different directions for each path - the first is ‘/’ the second is ‘\’. Before we potentially lock this down as being a symlink bug can you test with the slashes being the same direction for me.

Bat file:

REM working "C:\Program Files\Autodesk\Maya2020\bin\mayapy.exe" C:/temp/build_maya_scene.py
REM working "C:/Program Files/Autodesk/Maya2020/bin/mayapy.exe" C:/temp/build_maya_scene.py
REM crashes "C:/PROGRA~1/Autodesk/Maya2020/bin/mayapy.exe" C:/temp/build_maya_scene.py
REM crashes "C:\PROGRA~1\Autodesk\Maya2020\bin\mayapy.exe" C:/temp/build_maya_scene.py

A note about maya.standalone. It’s built into PyMel so if you do import pymel.core it will automatically run import maya.standalone; maya.standalone.initialize(name='python') behind the scenes, but the same won’t be true if you were using maya.cmds, which is why adding those extra lines doesn’t make a difference in this case.

My guess here is that passing the maya path to shell through os.system doesn’t actually resolve symlinks. It might work if you were to do:

import os

MAYAPY = os.realpath("C:/PROGRA~1/Autodesk/Maya2020/bin/mayapy.exe");

script = 'C:/build_maya_scene.py'
cmd = '{0} -t {1}'.format(MAYAPY, script)
os.system(cmd)

It is generally good practice to use os.path, os.realpath, os.path.sep, etc. when with working with file paths. Python on Windows will work fine if you use either / or \ but I believe it will break if you use \ on Linux / Mac

2 Likes

os.path.realpath("C:/PROGRA~1/Autodesk/Maya2020/bin/mayapy.exe") also crushes with os.system(cmd)