<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _find_executables(name):
 """ Try to find an executable. """

    exe_name = name + '.exe' * sys.platform.startswith('win')
    env_path = os.environ.get(name.upper()+ '_PATH', '')
    
    possible_locations = []
    def add(*dirs):
        for d in dirs:
            if d and d not in possible_locations and os.path.isdir(d):
                possible_locations.append(d)
    
    # Get list of possible locations
    add(env_path)
    try:
        add(os.path.dirname(os.path.abspath(__file__)))
    except NameError:  # __file__ may not exist
        pass
    add(os.path.dirname(sys.executable))
    add(os.path.expanduser('~'))
    
    # Platform specific possible locations
    if sys.platform.startswith('win'):
        add('c:\\program files', os.environ.get('PROGRAMFILES'),
            'c:\\program files (x86)', os.environ.get('PROGRAMFILES(x86)'))
    else:
        possible_locations.extend(['/usr/bin','/usr/local/bin','/opt/local/bin'])
    
    def do_check_version(exe):
        try:
            return subprocess.check_output([exe, '--version']).decode().strip()
        except Exception:
            # print('not a good exe', exe)
            return False
    
    # If env path is the exe itself ...
    if os.path.isfile(env_path):
        ver = do_check_version(env_path)
        if ver:
            return env_path, ver
    
    # First try to find obvious locations
    for d in possible_locations:
        for exe in [os.path.join(d, exe_name), os.path.join(d, name, exe_name)]:
            if os.path.isfile(exe):
                ver = do_check_version(exe)
                if ver:
                    return exe, ver
    
    # Maybe the exe is on the PATH
    ver = do_check_version(exe_name)
    if ver:
        return exe_name, ver
        
    # Try harder
    for d in possible_locations:
        for sub in reversed(sorted(os.listdir(d))):
            if sub.startswith(name):
                exe = os.path.join(d, sub, exe_name)
                if os.path.isfile(exe):
                    ver = do_check_version(exe)
                    if ver:
                        return exe, ver
    
    return None, None