code: def get_program_python(cmd):
      
      full_cmd = os.path.realpath(which(cmd))
      cmd_python = os.path.join(os.path.dirname(full_cmd), "python")
      env_python = None
      if "envs" in cmd_python:
          parts = cmd_python.split(os.sep)
          env_python = os.path.join(os.sep.join(parts[:parts.index("envs") + 2]), "bin", "python")
      if os.path.exists(cmd_python):
          return cmd_python
      elif env_python and os.path.exists(env_python):
          return env_python
      else:
          return os.path.realpath(sys.executable)
docs: Get the full path to a python version linked to the command.
  
      Allows finding python based programs in python 2 versus python 3
      environments.