MayaPy 2017 PythonInterpreter crash

452 views
Skip to first unread message

Erik Karlsson

unread,
Jan 26, 2017, 6:22:45 AM1/26/17
to Python Programming for Autodesk Maya
Hi everyone!

I'm trying to get maya 2017 up and working. But I'm having some issues.
This time it's the mayapy.exe. It's not behaving the way it did in 2016. I can't run it cleanly without a crash...

I get a windows popup saying PythonInterpreter has stopped working.

And this is the output from the commandline:

i:\python\scripts>"c:\Program Files\Autodesk\Maya2017\bin\mayapy.exe" testMayaPy.py
[u'frontShape', u'perspShape', u'sideShape', u'topShape']
Stack trace:
  python27
.dll!PyInterpreterState_Delete
  python27
.dll!PyGILState_Ensure
 
CommandEngine.dll!TpythonLock::initLock
 
ExtensionLayer.dll!TelfUtils::TelfUtils
 
ExtensionLayer.dll!TscriptAction::~TscriptAction
 
SharedUI.dll!TsetManipValueAction::callContext
 
SharedUI.dll!TelfIconTextButtonCmd::skipFlagForCreateCmd
 
SharedUI.dll!QmayaHotkeyEditor::qt_static_metacall
 
SharedUI.dll!QmayaHotkeyEditor::qt_static_metacall
  ntdll
.dll!RtlDeactivateActivationContextUnsafeFast
  ntdll
.dll!LdrShutdownProcess
  ntdll
.dll!RtlExitUserProcess
  KERNEL32
.DLL!ExitProcess
  MSVCR110
.dll!_initterm_e
  KERNEL32
.DLL!BaseThreadInitThunk
  ntdll
.dll!RtlUserThreadStart


the python file "testMayaPy.py" I'm running is simple and looks like this:

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

import maya.cmds as cmds

print cmds.ls(type='camera')

maya
.standalone.uninitialize()


It looks like the script runs fine but has troubles when exiting in 2017.
In Maya 2016 everything works fine. I get this output:

i:\python\scripts>"c:\Program Files\Autodesk\Maya2016\bin\mayapy.exe" testMayaPy.py
[u'frontShape', u'perspShape', u'sideShape', u'topShape']


Anyone else having similar problems, and possibly a workaround?

The idea is to batchprocess a bunch of maya files. But since I get a crash for every file in the loop, I need to click the annoying "Interpreter has stopped working" window for it to continue. So I managed to process 100 maya files with 100 clicks, which is not ideal...

thanks!
/Erik

Robert White

unread,
Jan 26, 2017, 10:00:51 AM1/26/17
to Python Programming for Autodesk Maya
I've had the interpreter crash a lot on exit due to plugins not unloading cleanly. Might be worth trying it with all of them disabled?

Justin Israel

unread,
Jan 26, 2017, 1:34:28 PM1/26/17
to Python Programming for Autodesk Maya
I've never used the uninitialize call. Does it crash when you don't use that? Does it provide important functionality in a shell script? 

I too have seen crashes during exit, and the quick fix can be to use os._exit(0)
This will force the python interpreter to exit quickly without calling any of the atexit shutdown handlers, which Maya can be using for plugin unloading and other shutdown operations. If you have done everything you need to do, closed and flushed all files and output, etc, then you may be fine with this approach. 

Justin 


--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/ee83fec9-9835-424e-831e-e31573b01f9e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Chad Vernon

unread,
Jan 26, 2017, 2:24:14 PM1/26/17
to Python Programming for Autodesk Maya
The uninitialize was introduced in 2016 and is required or else Maya crashes on exit...similar to this case!  I'm not sure why this case is crashing.  I tested your script in 2017 and it didn't crash.  Do you have any start up scripts running?  Anything in your MAYA_SCRIPT_PATH env?
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
Message has been deleted

Erik Karlsson

unread,
Jan 26, 2017, 2:52:49 PM1/26/17
to Python Programming for Autodesk Maya
Cool thanks for the insights! The os._exit(0) was a new one for me. It works! No more crashes. Great workaround.

Like Chad said, I learned to add the uninitialize call in 2016 and according to the maya documentation this is still valid for 2017. 
I disabled all my startup scripts I think.
I did this by calling these commands before executing the python script:

set MAYA_SCRIPT_PATH=''
set PYTHONPATH=''

Or is there something more that might be needed to be disabled? Is there another preferred way to disable the environments that is loading scripts and plugins?
If it works for Chad Vernon then there must be something wrong with my setup/installation/environment...
Reply all
Reply to author
Forward
0 new messages