code: def get_python_version(path):
      # type: (str) -> str
      
      version_cmd = [path, "-c", "import sys; print(sys.version.split()[0])"]
      try:
          c = vistir.misc.run(
              version_cmd,
              block=True,
              nospin=True,
              return_object=True,
              combine_stderr=False,
              write_to_stdout=False,
          )
      except OSError:
          raise InvalidPythonVersion("%s is not a valid python path" % path)
      if not c.out:
          raise InvalidPythonVersion("%s is not a valid python path" % path)
      return c.out.strip()
docs: Get python version string using subprocess from a given path.