run maya from command line in MacOS

1,636 views
Skip to first unread message

fruity

unread,
Apr 9, 2016, 8:13:30 AM4/9/16
to Python Programming for Autodesk Maya
Hello, 

I am working on mac OS, and have some issues trying to run Maya from the command line. At the moment, i don't have any feedback on what's going on when i run a plugin, as i don't have the output window (Windows), nor the bash window (Linux). So the idea would be to run Maya from the terminal, so it'll be able to output things in it. 

The problem is that when i run it from the terminal, it breaks my maya install. I did it for maya2013 for example, and now every time i open my maya (from the command line or from the Applications folder), i have some errors :
- "New default menu sets found" : New menu sets are available. Your menu set preferences must be updated to accept them, etc...
- "Shelf Error" : the shelf General has items that cannot be read, etc...

Once maya starts, i have brand new preferences, and i can't do anything (even creating a pSphere will return me a Syntax Error).
Maybe it could be because maya doesn't see my userSetup/mayaEnv files when i start it like that, causing some scripts to be not 'declared' to the application ?
I'm not sure that it's correct, and even if it is, do you have any idea on how i could fix that, by any chance ?
Can i run maya from the command line after giving it the same variable env that it has when i double click on the Maya.app icon ?

Any help would be really appreciated, it's really difficult to work without being able to print anything !
Thanks for your help =]

Justin Israel

unread,
Apr 9, 2016, 4:48:38 PM4/9/16
to Python Programming for Autodesk Maya
Hi,

I'm able to run "mayapy" just fine from an OSX terminal shell, which loads Maya's proper environment. 
What command are you running?

Justin

--
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 python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/5119a2da-9228-496b-87b5-050a64bfd65a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

vincent...@gmail.com

unread,
Apr 9, 2016, 5:07:19 PM4/9/16
to Python Programming for Autodesk Maya
Hi Justin, and thanks for your help, one more time =]
To run maya, i cd to the folder where Maya.app is (/Applications/Autodesk/maya201*/) and then i run :
Maya

I also tried to run the actual Maya file, located in Contents/bin, but same thing. What should i do with the mayapy before ? how do i 'run' it ? 'python mayapy' gives me an error in the .py file

Thank you

Justin Israel

unread,
Apr 9, 2016, 5:22:48 PM4/9/16
to python_in...@googlegroups.com
On Sun, Apr 10, 2016 at 9:07 AM <vincent...@gmail.com> wrote:
Hi Justin, and thanks for your help, one more time =]
To run maya, i cd to the folder where Maya.app is (/Applications/Autodesk/maya201*/) and then i run :
Maya

Yea, don't run that. 

$ find /Applications/Autodesk/maya2015/ -name "mayapy"
/Applications/Autodesk/maya2015//Maya.app/Contents/bin/mayapy


I also tried to run the actual Maya file, located in Contents/bin, but same thing. What should i do with the mayapy before ? how do i 'run' it ? 'python mayapy' gives me an error in the .py file

Don't run it as "python mayapy". It is actually a shell script
You should be able to run that mayapy (it's got executable permissions)

$ /Applications/Autodesk/maya2015//Maya.app/Contents/bin/mayapy
Python 2.7.3 (v2.7.3:70274d53c1dd, Apr  9 2012, 20:52:43)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin\
Type "help", "copyright", "credits" or "license" for more information.
>>> 

Or put it into your PATH so its always there:

*edit your ~/.bashrc file*
export PATH="${PATH}:/Applications/Autodesk/maya2015/Maya.app/Contents/bin"
 
Then it is always in your PATH:
$ mayapy

fruity

unread,
Apr 9, 2016, 5:35:00 PM4/9/16
to Python Programming for Autodesk Maya
So if i understand correctly, it is the mayapy file which is responsible for registering all maya env variables, like MAYA_SCRIPT_PATH, MAYA_PLUGIN_PATH, etc.... ?
Which means i don't need to export all those paths manually ?

For now, i added the path to mayapy in my bashrc file (export PATH="/Applications/Autodesk/maya2016/Maya.app/Contents/bin:$PATH"), but even if i start a new terminal and run Maya, it still doesn't work (by the way, the error on maya 2016 is different : Singular matrix, no inverse exists.. i have no idea of what that mean^^)
What is it that i'm doing wrong ?
Thank you


> To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

>
> To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/5119a2da-9228-496b-87b5-050a64bfd65a%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.

--
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 python_inside_maya+unsub...@googlegroups.com.

Justin Israel

unread,
Apr 9, 2016, 5:51:20 PM4/9/16
to python_in...@googlegroups.com
On Sun, Apr 10, 2016 at 9:35 AM fruity <fruit...@gmail.com> wrote:
So if i understand correctly, it is the mayapy file which is responsible for registering all maya env variables, like MAYA_SCRIPT_PATH, MAYA_PLUGIN_PATH, etc.... ?
Which means i don't need to export all those paths manually ?

Look at the contents of the shell script:
$ cat  /Applications/Autodesk/maya2016/Maya.app/Contents/bin/mayapy

It is a bootstrap script.


For now, i added the path to mayapy in my bashrc file (export PATH="/Applications/Autodesk/maya2016/Maya.app/Contents/bin:$PATH"), but even if i start a new terminal and run Maya, it still doesn't work (by the way, the error on maya 2016 is different : Singular matrix, no inverse exists.. i have no idea of what that mean^^)
What is it that i'm doing wrong ?

I don't have 2016 handy at the moment to test (and when I do, its on Linux), so I can't comment on that. Are you saying you don't even get a functional python interpreter when you run "mayapy"? You don't even get to the point where you can run "import maya.standalone; maya.standalone.initialize()" ?
 
> To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.

>
> To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/5119a2da-9228-496b-87b5-050a64bfd65a%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.

--
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 python_inside_m...@googlegroups.com.

--
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 python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/92314324-9b9c-4c97-94f0-559e8e0ed294%40googlegroups.com.

fruity

unread,
Apr 9, 2016, 6:19:17 PM4/9/16
to Python Programming for Autodesk Maya
when i run cat /Applications/Autodesk/maya2016/Maya.app/Contents/bin/mayapy, 
the terminal returns that :
path=`dirname $0`
pythonhome=$path/../Frameworks/Python.framework/Versions/Current
export PYTHONHOME=$pythonhome
export DYLD_LIBRARY_PATH=$path/../MacOS:$DYLD_LIBRARY_PATH
export DYLD_FRAMEWORK_PATH=$path/../Frameworks:$DYLD_FRAMEWORK_PATH
export MAYA_LOCATION=$path/..
exec $pythonhome/Resources/Python.app/Contents/MacOS/Python "$@"

And indeed, i just tried to run "import maya.standalone;maya.standalone.initialize()" in the mayapy interpreter, and get the same error (Error : Singular matrix, no inverse exists). I have this error with both maya2016 and maya2015.

Just to be sure, what is the exact syntax to run maya from the terminal ? Do i have to do something with mayapy, or executing only ".../maya2015/Maya.app" should work ?
Thank you
> To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

>
> To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/5119a2da-9228-496b-87b5-050a64bfd65a%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.

--
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 python_inside_maya+unsub...@googlegroups.com.

--
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 python_inside_maya+unsub...@googlegroups.com.

pierre brindel

unread,
Apr 9, 2016, 6:36:19 PM4/9/16
to python_in...@googlegroups.com
Hi fruity.

As a start you can launch maya from the terminal that is in the Maya2016 dir ( same level as Maya.app )
 that terminal run an sh /Applications/Autodesk/maya2016/Maya.app/Contents/bin/MayaENV.sh
This is setting your maya env and the terminal behaves like the output window you mentioned earlier.
simply type maya in term...

Hope this help.


the terminal returns that :
> To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.

>
> To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/5119a2da-9228-496b-87b5-050a64bfd65a%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.

--
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 python_inside_m...@googlegroups.com.

--
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 python_inside_m...@googlegroups.com.

--
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 python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/0dd038a3-365f-4c7b-a4b5-248291f2cf9a%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
------------------------------------
pierro...@gmail.com
------------------------------------

fruity

unread,
Apr 9, 2016, 6:50:05 PM4/9/16
to Python Programming for Autodesk Maya
Hi ! 

Thanks for your help ! This seems to open a custom shell ("Welcome to the Autodesk Maya 2016 shell"), unfortunately, i have the same errors than before. First the 'singular matrix' error, then another one telling me that some shelves are not found. And if i hit 'ok', let maya start, and quit it without killing the process, my install is corrupted (even if i delete the prefs folder) and many things will no longer work =[ I am running out of ideas, also because i don't understand perfectly what i'm doing, what maya needs to start, etc etc...



the terminal returns that :
> To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

>
> To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/5119a2da-9228-496b-87b5-050a64bfd65a%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.

--
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 python_inside_maya+unsub...@googlegroups.com.

--
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 python_inside_maya+unsub...@googlegroups.com.

--
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 python_inside_maya+unsub...@googlegroups.com.



--
------------------------------------
pierro...@gmail.com
------------------------------------

fruity

unread,
Apr 10, 2016, 7:16:29 AM4/10/16
to Python Programming for Autodesk Maya
Small update, in case someone else has the same problem !

I finally managed to fix this 'singular matrix' thing... I added to my env variables :
export LC_ALL=C

Although i have no idea of what it could mean (something to do with default language...), it seems to fix my issue \o/
I also found a few topics about it for maya 2016, seems to be related to openGL libraries.

Last thing (but not really critical, i think i'll find a solution soon or later^^) : i can't manage to run maya2015. Even though i navigate to the maya2015 folder to run 'maya', it's always the 2016 which is run, now. What can i do to run the correct maya, i.e. the one from where i run 'maya' ?

thanks for your help =]

Marcus Ottosson

unread,
Apr 10, 2016, 8:01:44 AM4/10/16
to python_in...@googlegroups.com

Even though i navigate to the maya2015 folder to run ‘maya’, it’s always the 2016 which is run

Try typing ./maya instead.

The terminal doesn’t account for your working directory when invoking commands, it only looks at $PATH. The ./ in front of maya tells it to run from your working directory. Alternatively, you can type the absolute path to the file, e.g. /opt/autodesk/maya2015/bin/maya


the terminal returns that :
> To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.

>
> To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/5119a2da-9228-496b-87b5-050a64bfd65a%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.

--
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 python_inside_m...@googlegroups.com.

--
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 python_inside_m...@googlegroups.com.

--
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 python_inside_m...@googlegroups.com.



--
------------------------------------
pierro...@gmail.com
------------------------------------

--
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 python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/2ea3293f-4b3b-4ec1-a657-81f08aad0876%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Marcus Ottosson
konstr...@gmail.com

fruity

unread,
Apr 10, 2016, 8:55:11 AM4/10/16
to Python Programming for Autodesk Maya
Hi Marcus !

Indeed, it worked, thanks =] i also had to override some env variables to make it work. 
cheers
the terminal returns that :
> To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

>
> To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/5119a2da-9228-496b-87b5-050a64bfd65a%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.

--
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 python_inside_maya+unsub...@googlegroups.com.

--
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 python_inside_maya+unsub...@googlegroups.com.

--
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 python_inside_maya+unsub...@googlegroups.com.



--
------------------------------------
pierro...@gmail.com
------------------------------------

--
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 python_inside_maya+unsub...@googlegroups.com.



--
Marcus Ottosson
konstr...@gmail.com

Reply all
Reply to author
Forward
0 new messages