To get the path to the Python interpreter executable file in Blender, we need to check the “bpy.app.binary_path_python” variable.
However, in Blender 2.93 and later, this variable has been removed from the API, and in order to get the desired path to python executable, we need to refer to the “sys.executable”.
The best way for scripting is to define a function that returns the full path to the python executable for any version of Blender:
1 2 3 4 5 6 7 8 9 10 11 |
def python_exec(): import os import bpy try: # 2.92 and older path = bpy.app.binary_path_python except AttributeError: # 2.93 and later import sys path = sys.executable return os.path.abspath(path) |
And call it when we need:
1 2 3 |
print(python_exec()) # C:\Program Files\blender2-93\2.93\python\bin\python.EXE |