import os import sys binary_path = os.readlink(sys.executable) if not(os.path.isabs(binary_path)): binary_path = os.path.join(os.path.dirname(sys.executable), os.readlink(sys.executable)) print(binary_path)