Thank you Ævar for respond.

Sure, here is the list of paths in my sys.path:

[...]

As for the Maya path, it is installed in :

/Applications/Autodesk/maya2014

-h
 
Cool, that looks all in order and default so it should be all 
straightforward, apart from the fact I only have Maya LT installed and am 
on Windows so I'm going to try to talk you through the process of achieving 
this rather me being able to send you practical snippets....

  What your are seeing in there are all the default paths which python 
looks for libraries in, the path where maya.cmds for example is installed 
is not there, and your error is a simple "I don't know the word you are 
trying to tell me" since no directory or file within that path exists.

  It's as simple as within your Maya install you will find a directory 
named maya, and within it cmds, that's your cmds module where you find 
among other things the ability to create a polyCube as per your example.

Mine is usually within Python\lib\site-packages, 
Windows example:
*C:\Program Files\Autodesk\Maya2014\Python\Lib\site-packages*
So presumably yours is at:
*/Applications/Autodesk/maya2014/Python/Lib/site-packages*


There are two ways to go about this

[ The dirty way, not good practice at all but works if you accept it for 
the hack it is as you are altering the system behaviour ]

import sys
path =* '/Applications/Autodesk/maya2014/Python/Lib/site-packages'*
sys.path.insert( 0, path ) # The zero puts it in front of all other 
libraries and it will pick up.

[ And the good way ]
You can add this path into your Sublime project settings, i.e.

myproject.sublime-project
{
    "folders":
    [
        {
            "path": 
"/Users/hsabri/Library/Preferences/Autodesk/maya/2014-x64/scripts/zepto/basic/"
        }
    ],
 
    "settings": {
        "python_interpreter_path": 
"/Library/Frameworks/Python.framework/Versions/3.4/bin",
 
        "python_package_paths": [
            // My python package path
            "*/Applications/Autodesk/maya2014/Python/Lib/site-packages"*

            // Maya's python stubs
            
"/Applications/Autodesk/maya2014/devkit/devkit/other/pymel/extras/completion/py/"
            ]
    }
}

  At this point I'd expect your editor to no longer complain about a 
missing maya module and you should be able to run:

import maya.cmds

  without errors, the error however will appear in your next line:
maya.cmds.polyCube()

 and this is where most people I've met trying this get confused. as there 
is one more step missing.  In order to make use of a standalone version of 
Maya you need to initialize it ( think of it as the same thing as opening 
the UI, the whole thing doesn't exist until that's taken place )

Close your editor and restart it, if you have imported maya.cmds without 
this part it most likely will not pick up if you try again, try this once 
you've restarted Sublime:

import maya.standalone
maya.standalone.initialize( 'python' )
import maya.cmds
maya.cmds.polyCube()

  The standalone libraries are installed alongside the cmds module and as 
long as you have a fully licensed copy of Maya this will pull only a batch 
license as far as I'm aware of.

  I assume you then run the code by simply selecting Tools > Build which 
runs your code and initializes the library each time?  ( more proper is to 
make your file executable but that trick works for quick dev at your own 
risk of course.. )

p.s. As Justin mentions don't use python 3.3 with Maya 2014, it kinda gives 
the impression that it works most of the time but you will get into some 
seriously interesting debug sessions, stick with what Autodesk provide.

  Let us know how you get on, the 4 lines above along with your Sublime 
config should be enough to get this going ( up to the auto completion part 
at least but it sounds like you have that covered. )


-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/7757bd23-1c15-450b-a8e4-cdcf2eed89c0%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to