0

I setup Eclipse IDE for editing and debugging Maya scripts. When I try to run the code:

import maya.cmds as cmds cmds.ls() 

in Eclipse I get the error:

 import maya.cmds as cmds NameError: Can't find file for module maya (filename C:\Users\shivani\My Documents\maya) 

I configured eclipse to use maya and python like the following:

enter image description here

I don't understand what is the problem or I'm not able to use Eclipse properly?

2 Answers 2

1

Configure Eclipse to use mayapy Python interpreter available in <Maya_INSTALL_DIR>\bin.

Or else you will have to initialize the default Python interpreter with Maya as explained here.

Sign up to request clarification or add additional context in comments.

1 Comment

I have configured Eclipse to use mayapy.exe already. I followed all the installation process step by step and set the environment variables too. I would re do and see what happens. Thanks.
0

If you're running this in Eclipse you'll also have to add

import maya.standalone try: maya.standalone.initialize() except: print "standalone already running" 

to any code you try to run in the external interpreter.

The maya module is just an empty stub unless running inside a live Maya session or after importing maya.standalone and initializing it as above. The try-catch is good practice because you can only initialize a standalone once.

2 Comments

OP's error states NameError: Can't find file for module maya meaning maya is not in the path and I think that needs to be taken care of first.
I tried the with the standalonebut it gives the same error. So I guess I have to re check the installation process again. Thanks.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.