find_executable
- pyhelpers.ops.find_executable(app_name, possibilities=None)
Get pathname of an executable file for a specified application.
- Parameters
app_name (str) – executable filename of the application that is to be called
possibilities (list or set or None) – possible pathnames
- Returns
pathname of the specified executable file and whether it exists
- Return type
Tuple[str, bool]
Examples:
>>> from pyhelpers.ops import find_executable >>> import os >>> python_exe = "python.exe" >>> possible_paths = ["C:\Program Files\Python39", "C:\Python39"] >>> path_to_python_exe, python_exe_exists = find_executable(python_exe, possible_paths) >>> os.path.relpath(path_to_python_exe) 'venv\Scripts\python.exe' >>> python_exe_exists True >>> text_exe = "pyhelpers.exe" # This file does not actually exist >>> path_to_test_exe, test_exe_exists = find_executable(text_exe, possible_paths) >>> path_to_test_exe 'pyhelpers.exe' >>> test_exe_exists False