what is running python?

29 views
Skip to first unread message

Todd Widup

unread,
Jun 1, 2015, 12:33:57 PM6/1/15
to python_in...@googlegroups.com
is there a way to find out what program called the python script that is running?

IE, if its running in Maya, Soft, Houdini, idle, or something else even.

thanks
-todd

--
Todd Widup
Creature TD / Technical Artist
to...@toddwidup.com
todd....@gmail.com
www.toddwidup.com

Timm Wagener

unread,
Jun 1, 2015, 12:51:33 PM6/1/15
to python_in...@googlegroups.com
I have done something like this with the sys module.

import sys
print(sys.executable)

Then you get the path to the interpreter running on your script and can parse it (for example for "mayapy") and make some decisions.


Maybe there are also other, better ways!
Cheers,
Timm

--
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/CABBPk361T%2BE%2BMyP4VGnz-Xv%2B3b_ONDpCTJSmw7TDJ%3D5FwEuS8g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.



--
Timm Wagener
Technical Artist / 3D Generalist

www.timmwagener.com

Email:
wagen...@gmail.com

Phone:
0178-2810920


Martin Chatterjee

unread,
Jun 1, 2015, 12:53:46 PM6/1/15
to python_in...@googlegroups.com
Hi Todd,

yeah, this should work:

import sys
print sys.executable


Cheers, Martin
--
       Martin Chatterjee

 
[ Freelance Technical Director ]
[   http://www.chatterjee.de   ]

On Mon, Jun 1, 2015 at 6:33 PM, Todd Widup <todd....@gmail.com> wrote:

--

Brennan Chapman

unread,
Jun 1, 2015, 12:54:29 PM6/1/15
to python_in...@googlegroups.com
Take a look at sys.executable
Returns the path to the python executable.

On mac I get this from mayapy:
'/Applications/Autodesk/maya2015/Maya.app/Contents/bin/../Frameworks/Python.framework/Versions/Current/Resources/Python.app/Contents/MacOS/Python’

compared to running straight python:
'/usr/local/opt/python/bin/python2.7'


import sys
print sys.executable

Todd Widup

unread,
Jun 1, 2015, 12:59:33 PM6/1/15
to python_in...@googlegroups.com
thanks guys...was looking all of stackoverflow this weekend and couldn't find anything with a search, much appreciated



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

Martin Chatterjee

unread,
Jun 1, 2015, 3:50:40 PM6/1/15
to python_in...@googlegroups.com
Hi Todd,

yeah, this should work:

import sys
print sys.executable


Cheers, Martin
--
       Martin Chatterjee

 
[ Freelance Technical Director ]
[   http://www.chatterjee.de   ]

On Mon, Jun 1, 2015 at 6:33 PM, Todd Widup <todd....@gmail.com> wrote:

--
Reply all
Reply to author
Forward
0 new messages