def find_executable(executable: str, *paths: str) -> typing.Optional[Path]:
if not executable.endswith('<STR_LIT>'):<EOL><INDENT>executable = f'<STR_LIT>'<EOL><DEDENT>if executable in _KNOWN_EXECUTABLES:<EOL><INDENT>return _KNOWN_EXECUTABLES[executable]<EOL><DEDENT>output = f'<STR_LIT>'<EOL>if not paths:<EOL><INDENT>path = os.environ['<STR_LIT>']<EOL>paths = tuple([str(Path(sys.exec_prefix, '<STR_LIT>').absolute())] + path.split(os.pathsep))<EOL><DEDENT>executable_path = Path(executable).absolute()<EOL>if not executable_path.is_file():<EOL><INDENT>for path_ in paths:<EOL><INDENT>executable_path = Path(path_, executable).absolute()<EOL>if executable_path.is_file():<EOL><INDENT>break<EOL><DEDENT><DEDENT>else:<EOL><INDENT>_LOGGER.error('<STR_LIT>', output)<EOL>return None<EOL><DEDENT><DEDENT>_KNOWN_EXECUTABLES[executable] = executable_path<EOL>_LOGGER.info('<STR_LIT>', output, str(executable_path))<EOL>return executable_path<EOL>
Based on: https://gist.github.com/4368898

Public domain code by anatoly techtonik <techtonik@gmail.com>

Programmatic equivalent to Linux `which` and Windows `where`

Find if ´executable´ can be run. Looks for it in 'path'
(string that lists directories separated by 'os.pathsep';
defaults to os.environ['PATH']). Checks for all executable
extensions. Returns full path or None if no command is found.

Args:
    executable: executable name to look for
    paths: root paths to examine (defaults to system PATH)

Returns: executable path as string or None