def _get_gs_path():
    """Guess where the Ghostscript executable is
    and return its absolute path name."""
    path = os.environ.get("PATH", os.defpath)

    for dir in path.split(os.pathsep):
        for name in ("gs", "gs.exe", "gswin32c.exe"):
            g = os.path.join(dir, name)
            if os.path.exists(g):
                return g
    raise Exception("Ghostscript not found. path=%s" % str(path))
Guess where the Ghostscript executable is
    and return its absolute path name.