import sys from os.path import abspath from distutils.spawn import find_executable exe = find_executable('binary_name') if not exe: print('[ERROR] Binary not found in your $PATH variable!') sys.exit(1) else: exe = abspath(pluto)