8

Possible Duplicate:
How to get current python interpreter path from inside a Python script?

The title pretty much says it. I'd like to know which python executable is being used from inside python. Something like

Python 2.7.2 (default, Nov  1 2011, 03:31:17)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> print <insert the code I'm after here>
/usr/local/bin/python2.7
>>>
Python 2.6.6 (r266:84292, Dec 27 2010, 00:02:40)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> print <insert the code I'm after here>
/usr/bin/python2.6
>>>

You get the picture

Thanks

0

2 Answers 2

14

You can do this:

>>> import sys
>>> print sys.executable
/usr/bin/python

as described here: How to get the python.exe location programmatically?

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

Comments

1

Why not just use the bash where command?

Anyways, here is what you're looking for:

import sys
sys.executable

3 Comments

Maybe he needs the name of the executable of that particular instance, and it can be any program linked with Python's library.
Great! - Wait, why wasn't I up voted or ticket? o.O
its which python command not where !!!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.