471,599 Members | 1,145 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,599 software developers and data experts.

"which python" as a python command?

Hello,

I'm trying to find out in a script where the location of the current
python is. (I'm writing an installer script in python for a simple
server application, so i'm going to do a find-replace in a bunch of
files to give them the absolute path of the python binary.

One thought might be to use the subprocess module, run "which python"
as a subprocess, and then peek at stdout, but that seems way too
complicated. Is there a simple solution for this in just a few lines
of code?

Cheers,
Evan
Sep 25 '08 #1
2 1428
ch******@gmail.com wrote:
Hello,

I'm trying to find out in a script where the location of the current
python is.
import sys
print sys.executable

HTH,

--
Carsten Haese
http://informixdb.sourceforge.net
Sep 25 '08 #2
On Sep 25, 11:14*am, Carsten Haese <carsten.ha...@gmail.comwrote:
import sys
print sys.executable
This is exactly what I needed. Thanks!
Sep 25 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by marco | last post: by
reply views Thread by python-help-bounces | last post: by
12 posts views Thread by beliavsky | last post: by
30 posts views Thread by bblais | last post: by
9 posts views Thread by Jameson.Quinn | last post: by
92 posts views Thread by ureuffyrtu955 | last post: by
reply views Thread by martin.nordstrom87 | last post: by
2 posts views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by Anwar ali | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.