Eclipse environment for Maya's python modules
Question: I'm trying to set up the Eclipse IDE to recognize the **maya.cmds** module, an
all modules associated with the **maya** module. The following code are tests
run in Eclipse, and Maya's script editor.

    
    
    import maya
    print 'maya:\n', dir(maya)
    
    from maya import cmds
    print 'cmds:\n', len(dir(cmds)) # too many to print
    
    print 'sphere: ', cmds.sphere
    

In Maya's script editor the code results in

    
    
    maya:
    ['OpenMaya', '_OpenMaya', '__builtins__', '__doc__', '__file__', '__name__', '__package__', '__path__', 'app', 'cmds', 'mel', 'standalone', 'stringTable', 'utils']
    
    cmds:
    3190
    
    sphere: <built-in method sphere of module object at 0x0000000019F0EEE8>
    

In Eclipse the code results in

    
    
    maya:
    ['__builtins__', '__doc__', '__file__', '__name__', '__package__', '__path__']
    
    cmds:
    6
    
    sphere: 
    Traceback (most recent call last):
    AttributeError: 'module' object has no attribute 'sphere'
    

I've done a lot of searching, on the google group "python inside maya", and
web searches. The best I've found was the following link, however this did not
solve my issue at all, and in the end gave the same result. <http://www.luma-
pictures.com/tools/pymel/docs/1.0/eclipse.html>

I've read that I should be setting my environment paths in Eclipse, rather
than my machine, and I've also read the opposite opinion. What environment
vars should I set, to where, and in Eclipse, Windows, or both?


Answer: The solution is to import maya.standalone and initialize it. This gives you
access to the maya packages and modules therein.

    
    
    import maya.standalone
    maya.standalone.initialize()
    
    import maya
    print 'maya:\n', dir(maya)
    
    from maya import cmds
    print 'cmds:\n', len(dir(cmds)) # too many to print
    
    print 'sphere: ', cmds.sphere
    

output:

    
    
    maya:
    ['__builtins__', '__doc__', '__file__', '__name__', '__package__', 
    '__path__', 'app', 'cmds', 'mel', 'standalone', 'stringTable', 'test', 'utils']
    
    cmds:
    2945
    
    sphere:  <built-in method sphere of module object at 0xf33948>
    

