Python installed path

sys.executable

A string giving the absolute path of the executable binary for the Python interpreter, on systems where this makes sense. If Python is unable to retrieve the real path to its executable, sys.executable will be an empty string or None.

>>> import sys
>>> sys.executable
'C:\\Python310\\python.exe'

os.path.dirname(path)

Return the directory name of pathname path. This is the first element of the pair returned by passing path to the function split().

>>> import os
>>> import sys
>>> os.path.dirname(sys.executable)
'C:\\Python310'
>>> import os
>>> import sys
>>> os.path.dirname(sys.executable)
'C:\\Users\\<username>\\AppData\\Local\\Programs\\Python\\Python38\\python.exe'