sys.executable

The full path of the Python interpreter file that is running the current program.

In more detail

Printing it answers which Python am I beyond doubt, which matters when several are installed or a virtual environment is involved. Running sys.executable -m pip installs packages into exactly that interpreter.

Example

import sys
print(sys.executable)

Related terms

Taught in

References