0

I am trying to run a python script using maya's python interpreter. I am writing this script to be placed in a pipeline, so that maya runs in batchmode. Nothing is happening when I run this command:

maya -batch -script maya.py $1

I get the following message after running this command:
link here

I also tried using the python interpreter directly with a test file

/Applications/Autodesk/maya2017/Maya.app/Contents/bin/mayapy test.py

test.py looks like this

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

I get this error ImportError: No module named cmds

I have looked at this post, but it did not help me. What am I doing wrong?

Mofi
  • 46,139
  • 17
  • 80
  • 143
luii
  • 319
  • 3
  • 5
  • 16
  • what happens if you run this in Mayapy:`import sys; print sys,prefix ` – theodox Jun 28 '17 at 16:45
  • I get this /Applications/Autodesk/maya2017/Maya.app/Contents/bin/../Frameworks/Python.framework/Versions/Current – luii Jun 28 '17 at 17:53
  • Can you run mayapy from a terminal without passing in a file argument? – theodox Jun 28 '17 at 17:56
  • @theodox yes I can – luii Jun 28 '17 at 18:01
  • are you running any python plugins? – theodox Jun 28 '17 at 18:01
  • @theodox no I am not. – luii Jun 28 '17 at 18:03
  • and if you run mayapy from the terminal and `import maya.standalone; maya.standalone.initialize()` fails the same way interactively? – theodox Jun 28 '17 at 18:36
  • @theodox I get ImportError: No module named cmds – luii Jun 28 '17 at 19:20
  • @luii so, if you run a python file which doesn't import any maya-related module, it works? Can you confirm that `import sys; print sys.prefix` doesn't throw any exception? What if in `test.py` you simply run: `import maya.standalone` without anything else? Does it still throw the error `ImportError: No module named cmds`? – mapofemergence Jun 29 '17 at 00:16
  • @mapofemergence to your first question it does not throw an exception. Second, I get this error ImportError: No module named standalone – luii Jun 29 '17 at 16:09
  • Could there be a problem in my env variables? mayapy='/Applications/Autodesk/maya2017/Maya.app/Contents/bin/mayapy' . export MAYA_LOCATION=/Applications/Autodesk/maya2017/Maya.app/Contents export PATH=$MAYA_LOCATION/bin:$PATH export PYHTONPATH=/opt/X11/lib/python2.6/site-packages – luii Jun 29 '17 at 16:49
  • I am also using a student version of maya – luii Jun 29 '17 at 16:52
  • is it `export PYHTONPATH=/opt/X11/lib/python2.6/site-packages` or `export PYHTONPATH=$PYHTONPATH:/opt/X11/lib/python2.6/site-packages`? If it is the former, could you try the latter? (I'm assuming `/opt/X11/lib/python2.6/site-packages` is to add packages from your your python installation folder, right?) Also, could you try `import sys; print sys.path` in your `test.py` file? – mapofemergence Jun 29 '17 at 17:48
  • Now I am getting "RuntimeError: maximum recursion depth exceeded while calling a Python object" – luii Jun 30 '17 at 15:58
  • On this line file /Applications/Autodesk/maya2017/Maya.app/Contents/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/ipython_genutils-0.2.0-py2.7.egg – luii Jun 30 '17 at 16:10
  • @luii I'm a bit confused, as I don't understand what is making your errors change... it started with `ImportError: No module named cmds`, it then became `ImportError: No module named standalone` and now it is a `RuntimeError`. Could you take some time and edit your answer, writing the steps to reproduce all these errors? It is very hard to understand what's happening, if the conditions of your tests change. If you can't reproduce those steps, you might want to re-install Maya before going any further (I usually do not suggest this but, in this case, it might be wiser to start afresh) – mapofemergence Jul 01 '17 at 11:35
  • also, it'd be helpful if you could add in your answer a full version, cleanly formatted, of the file you're using to set the env variables and specify where it lives (or how you're sourcing it) – mapofemergence Jul 01 '17 at 12:04
  • have you solved the problem? I have the same issue – Changkun Jun 21 '19 at 06:58
  • @Jakob I think I ended up running the code in a docker container that it worked in, but this was over 2 years ago so I do not remember. – luii Jun 22 '19 at 04:48

0 Answers0