pymel in mayapy.exe hanging

274 views
Skip to first unread message

hapgilmore

unread,
Sep 10, 2010, 1:20:24 PM9/10/10
to python_inside_maya
I'm trying to set up an automated asset testing service on a server.

We use TeamCity to run a python script, which in turn imports pymel
and starts a maya shell to perform the asset testing.

TeamCity runs the python script under a Windows Service (which has
limited access to windows resources) , and it appears that something
about this method causes the "import pymel.core as pm" command to hang
mayapy.exe.

Running the python script on the server from the command line works
fine.

Any ideas what pymel could be accessing that wouldn't work when run as
part of a service?

hapgilmore

unread,
Sep 21, 2010, 3:29:54 PM9/21/10
to python_inside_maya
I posted this bug on the pymel issues page. (http://code.google.com/p/
pymel/issues/list) Haven't had a reply in a week. (I posted a bug a
year ago, still no reply)
Also, I filed a bug with autodesk through our studio's support
contract. Autodesk said i'm S.O.L, as pymel isn't supported.

What do you guys recommend to get any help/support with pymel bugs.
Now that my studio is starting to use pymel more, are we at risk
depending on an unsupported tool? Do you guys just get used to
solving issues on your own?

Chris G

unread,
Sep 21, 2010, 8:22:17 PM9/21/10
to python_in...@googlegroups.com
It might be that maya can't run as a windows service. I'm not
familiar with windows services, but there must be a way to edit the
security policies ?

> --
> http://groups.google.com/group/python_inside_maya

Paul Molodowitch

unread,
Sep 22, 2010, 1:48:41 PM9/22/10
to python_in...@googlegroups.com, hapgilmore
Hey there - first of all, I'm sorry I didn't notice your earlier issue.  We try to scan this list for pymel related stuff and respond, but sometimes we miss stuff...

However, regarding some of your questions about pymel support: well, there is no official support.  It is still being actively developed, and we try to get to tickets when we can.... but having said that, we don't receive any money for pymel, so our time is essentially donated to the project, and sometimes we simply don't have much time to devote to pymel.  There is a chance that you will have to end up troubleshooting on your own though - all of pymel is open source, and it's all python, so you should be able to use all the usual python-debugging tricks.

It can help to email Chad (cha...@gmail.com) or I (elro...@gmail.com) directly... particularly if you want to let us know about something urgent / important for your project / pipe.

Anyway, to the issue at hand - my guess is that Chris is on the right track - it's probably the process of starting maya itself that's causing the problem.  Ie, does doing this:

import maya.standalone
maya.standalone.initialize()

...in your service also result in a crash? If so, that's the issue... whenever pymel.core is imported, if maya isn't already running, it tries to start it by doing the above two lines (as pymel.core requires a running maya to do anything).

If that isn't it, I'll try to figure out what's wrong when I get home later tonight.  Also, some general debugging stuff you can try:

1) enable pymel logging

To do this, go to your pymel directory (if you're using the default install, somewhere inside the maya install... don't remember where exactly it puts it in windows, but I think it's in %MAYA_INSTALLATION%\Python...), and find the file called pymel.conf.  You'll need to either edit this in this location, or copy it to your home directory... (if no %HOME% environment variable is defined, you'll need to define that...), or define a %PYMEL_CONF% environment var, and have it contain the location of wherever you'd like you're pymel.conf to be.

Once you've got that, you'll need to add 'fileLogger' to the logger_pymel handlers... ie, change this:

[logger_pymel]
## Set the root 'pymel' logger to DEBUG mode
## Setting PYMEL_LOGLEVEL environment variable will override this
level=INFO
qualname=pymel
handlers=

to this:

[logger_pymel]
## Set the root 'pymel' logger to DEBUG mode
## Setting PYMEL_LOGLEVEL environment variable will override this
level=DEBUG
qualname=pymel
handlers=fileLogger

Once you've done that, pymel should log stuff to your homeDir/pymel.log... which may at least give us an idea of how far it gets before it crashes.

Another option would be:

2) Remote debugging

More powerful / useful, but you'll need an IDE that supports it (and can also be more involved to get working).  Both eclipse and Wing support remote debugging; exactly how to go about setting it up depends on what IDE you're using.  For eclipse + pydev, the process is explained here:


...but the basic idea is that you'd insert code like this:

import sys
sys.path.append(r'D:\bin\eclipse_36_final\plugins\org.python.pydev.debug_1.6.1.2010072814\pysrc')
import pydevd
pydevd.settrace()

...into wherever you're importing pymel.core, right before the pymel.core import.  Then you'd fire up eclipse, and go to the python debugging view, and click on the button to hook up to a remote debugging session.

- Paul


hapgilmore

unread,
Sep 22, 2010, 2:26:21 PM9/22/10
to python_inside_maya
Thanks for the suggestions, I really appreciate your help.

I am already remote debugging with Wing, though I could never get a
connection on the server.

I spent a couple hours yesterday setting up my local machine to
replicate the environment on the server. It turns out that because
the Windows Service isn't run as a regular user with regular
permissions, maya standalone won't launch.
On my local machine, the service pops up a warning (from the maya
instance) that a valid MAYA_APP_DIR can be found.
I assume that because I was using a remote desktop connection to the
server, I never sawt the pop-up, and the process wasn't really
hanging, just waiting for user input.

Now I just need to figure out how to give maya a valid MAYA_APP_DIR
under a service, which doesn't have the same user/system permissions
that a regular user login gives.

-Ian



On Sep 22, 11:48 am, Paul Molodowitch <elron...@gmail.com> wrote:
> Hey there - first of all, I'm sorry I didn't notice your earlier issue.  We
> try to scan this list for pymel related stuff and respond, but sometimes we
> miss stuff...
>
> However, regarding some of your questions about pymel support: well, there
> is no official support.  It is still being actively developed, and we try to
> get to tickets when we can.... but having said that, we don't receive any
> money for pymel, so our time is essentially donated to the project, and
> sometimes we simply don't have much time to devote to pymel.  There is a
> chance that you will have to end up troubleshooting on your own though - all
> of pymel is open source, and it's all python, so you should be able to use
> all the usual python-debugging tricks.
>
> It can help to email Chad (chad...@gmail.com) or I (elron...@gmail.com)
> sys.path.append(r'D:\bin\eclipse_36_final\plugins\org.python.pydev.debug_1. 6.1.2010072814\pysrc')
> import pydevd
> pydevd.settrace()
>
> ...into wherever you're importing pymel.core, right before the pymel.core
> import.  Then you'd fire up eclipse, and go to the python debugging view,
> and click on the button to hook up to a remote debugging session.
>
> - Paul
>
>
>
> On Tue, Sep 21, 2010 at 5:22 PM, Chris G <cgreb...@gmail.com> wrote:
> > It might be that maya can't run as a windows service.  I'm not
> > familiar with windows services, but there must be a way to edit the
> > security policies ?
>
> > On Tue, Sep 21, 2010 at 3:29 PM, hapgilmore <hapgilm...@hotmail.com>

John Creson

unread,
Sep 22, 2010, 7:46:52 PM9/22/10
to python_in...@googlegroups.com

mhaen...@goodgamestudios.com

unread,
Sep 18, 2015, 5:05:47 AM9/18/15
to Python Programming for Autodesk Maya
Hello I have had the same problem with Pymel for Maya 2015.
What I wanted to do is to start mayapy.exe as a new process from C# and relink the standard I/O back to C#. It worked out when I was loading packages from the from maya-module, it always hung up when I tried to implement pymel.core.
Our pipeline highly depends on Pymel so using cmds is not an option.
Interesting fact: Without rerouting the standard I/O this works very well, so importing pymel.core did not gave me any freeze. Unfortunately not having an output is no option in this project.

What I did was to set the "RedirectStandardError" Flag to false, thus the process-call looks like:

ProcessStartInfo PythonStartInfo = new ProcessStartInfo()
{
FileName = "C:/Program Files/Autodesk/Maya2015/bin/mayapy.exe",
Arguments = this.OutputScriptPath + " " + this.AssetPath,
//CreateNoWindow = true,
UseShellExecute = false,
RedirectStandardInput = true,
RedirectStandardOutput = true,
RedirectStandardError = false
};
MayaPythonProc = new Process();
MayaPythonProc.StartInfo = PythonStartInfo;

After calling it that way I'm able to get the output from python and use input data from C# directed to python as well.

I'm posting this cause it might give you an idea why the server-stuff did not work out the way you wanted and maybe someone else is currently trying what I'm doing here.

Best regards

Mirko
Reply all
Reply to author
Forward
0 new messages