Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find full path of the Python interpreter?

Tags:

python

path

How do I find the full path of the currently running Python interpreter from within the currently executing Python script?

like image 314
vy32 Avatar asked Apr 07 '10 02:04

vy32


People also ask

How do I find the Python interpreter path?

First, press Start in the lower-left corner then press Search followed by all files and folders. Type python.exe in the top text line that shows up and then press the search. A folder name will be listed where Python got installed. Hence the folder name becomes the path of Python.

Where is Python interpreter path in Windows?

Steps on WindowsOpen Search and Type Edit the System Environment Variables. Then Click on the "Environment Variables" Button in the Down Corner. There you can see all of the paths associated to where python, pip and other binaries are located that you call on command line.

Where is Python interpreter located Linux?

The Python3 interpreter is located under /usr/bin/python3. x . Once it's done, you can open the program and start coding.


2 Answers

Just noting a different way of questionable usefulness, using os.environ:

import os python_executable_path = os.environ['_'] 

e.g.

$ python -c "import os; print(os.environ['_'])" /usr/bin/python 
like image 26
famousgarkin Avatar answered Sep 17 '22 07:09

famousgarkin


sys.executable contains full path of the currently running Python interpreter.

import sys  print(sys.executable) 

which is now documented here

like image 129
Imran Avatar answered Sep 17 '22 07:09

Imran