Hey there - first, thanks for looking into that, and letting me know what
the issue was.  I looked into it some more myself, and found that pymel does
have problems when it's imported inside a plugin, and you're using 'maya
-prompt'.  I went ahead and made some changes to remedy this in the latest
version on github.

However, I'm hesitant to say that pymel really supports this, since I think
the whole idea of using any sort of maya.cmds stuff inside of a plugin
resides in a sort of gray area.  It may work, but there's a decent chance
you'll get yourself into trouble if you mix the two.

Of course, not all of pymel relies on maya.cmds stuff, and starting in pymel
1.0 there was a reorganization of some of the modules to help segregate the
stuff that does / does not rely on maya.cmds.  In particular, importing and
use of pymel.util should be safe and useable ANYWHERE (even if maya or it's
modules - such as maya.cmds - are not available / installed); and importing
and use of pymel.api should be safe as long as the maya modules are
available - ie, it will be usable within plugins, and in contexts where a
running maya instance is not available.  The other modules generally require
a running maya instance, and should not be considered safe within plugins.

- Paul

On Wed, Sep 29, 2010 at 1:00 PM, [email protected] <
[email protected]> wrote:

> In case this happens to anyone else, I eventually tracked down the
> problem to being a python plugin that was importing pymel.  I don't
> remember reading that this was a problem (which it only was in batch
> mode) and maybe it has something to do with the rest of our setup but
> removing all pymel from plugins got everything working again.
>
> On Aug 6, 2:18 pm, "[email protected]"
> <[email protected]> wrote:
> > For some reason, after months of everything being fine, pymel
> > mysteriously is broken in command line mode for me.
> >
> > "mayaBatch -prompt", will give the following results:
> >
> > mel: python "import pymel"
> > Error: line 1: 'module' object has no attribute 'util'
> > # Traceback (most recent call last):
> > #   File "<maya console>", line 1, in <module>
> > #   File "R:\Tools\Maya\3rdParty\scripts\pymel-0.9.3\pymel
> > \__init__.py", line 1490, in <module>
> > #     import core.factories as factories
> > #   File "R:\Tools\Maya\3rdParty\scripts\pymel-0.9.3\pymel\core
> > \__init__.py", line 5, in <module>
> > #     from general import *
> > #   File "R:\Tools\Maya\3rdParty\scripts\pymel-0.9.3\pymel\core
> > \general.py", line 21, in <module>
> > #     import pymel.util as util
> > # AttributeError: 'module' object has no attribute 'util'
> >
> > Some stats:
> > Vista (64bit but using the 32bit version of Maya because of other
> > plugins)
> > Maya2008
> > Pymel 0.9.3
> >
> > I have also tried using mayapy, which is able to import pymel, but my
> > other scripts aren't able to load pymel; it is very confusing.
> >
> > To make it even more confusing, in Jan of this year (2010) we upgraded
> > from 0.7.8 to 0.9.2 and everything continued to work till a few weeks
> > ago some machines stopped while others continued just fine till now.
> > Something happened and no machine can run in batch mode now.
> >
> > I put together a fresh machine a couple weeks ago and found that it
> > was unable to run in batch while my main dev machine continued to be
> > able to run in batch.  All the maya scripts and such are in source
> > control so I synced back till I had the fresh machine running in batch
> > mode.  I then crept up till it couldn't run and found that magic
> > moment was when we finally upgraded pymel in Jan.  This means that my
> > dev machine was able to function mysteriously for over 7 months.
> >
> > In all of this, the regular Maya version has worked, and continues to
> > work perfectly.
> >
> > The last notable bit of strangeness is that sys.modules HAS pymel.util
> > (and others) so I can do this:
> >
> > python "sys.modules['pymel.util'].capitalize('wtf')"
> > Result: Wtf
> >
> > But I can't do 'python "import pymel"' or any variant of that.
> >
> > Has anyone seen anything like this or have any ideas on how to figure
> > out what is going on?
>
> --
> http://groups.google.com/group/python_inside_maya
>

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

Reply via email to