1

Possible Duplicate:
Getting python.exe path at run time

I have a python app that launches other apps with explicit calls to C:\python25\python.exe, but this doesn't work if the user has 2.6 installed or if they have it installed to another location. There is a %PYTHON% variable for the exe, but this is only available to the user who installed Python (other users don't have this envvar set).

Is there another way to look up this location?

Cœur
  • 37,241
  • 25
  • 195
  • 267
directedition
  • 11,145
  • 18
  • 58
  • 79

3 Answers3

9
import sys
print sys.executable
nosklo
  • 217,122
  • 57
  • 293
  • 297
4
>>> import sys
>>> sys.executable
'C:\\Program Files\\Python31\\pythonw.exe'
SilentGhost
  • 307,395
  • 66
  • 306
  • 293
1

Consider using execfile. This executes the script you want using the same python instance that's already running.

recursive
  • 83,943
  • 34
  • 151
  • 241