Graphify-Labs/graphify · error · RuntimeError

Google Sheets export requires the office extra: pip install

Error message

Google Sheets export requires the office extra: pip install graphifyy[office,google]

What it means

Raised when exporting a .gsheet shortcut to markdown: the flow downloads the sheet as .xlsx via gws and then converts it with xlsx_to_markdown, which is imported lazily from graphify's office tooling. If that import failed at module load (xlsx_to_markdown is None), the office extra (openpyxl etc.) is missing and the error names the extra install — note the message's 'graphifyy[office,google]' spelling mirrors the packaged extra name.

Source

Thrown at graphify/google_workspace.py:211

        out_path.write_text(_with_frontmatter(path, shortcut, body, "text/markdown"), encoding="utf-8")
        return out_path

    if ext == ".gslides":
        with tempfile.NamedTemporaryFile("w+b", suffix=".txt", delete=False, dir=out_dir) as tmp:
            tmp_path = Path(tmp.name)
        try:
            _run_gws_export(shortcut["file_id"] or "", "text/plain", tmp_path, shortcut.get("resource_key"))
            body = tmp_path.read_text(encoding="utf-8", errors="replace")
        finally:
            tmp_path.unlink(missing_ok=True)
        if not body.strip():
            return None
        out_path.write_text(_with_frontmatter(path, shortcut, body, "text/plain"), encoding="utf-8")
        return out_path

    if ext == ".gsheet":
        if xlsx_to_markdown is None:
            raise RuntimeError("Google Sheets export requires the office extra: pip install graphifyy[office,google]")
        with tempfile.NamedTemporaryFile("w+b", suffix=".xlsx", delete=False, dir=out_dir) as tmp:
            tmp_path = Path(tmp.name)
        try:
            _run_gws_export(
                shortcut["file_id"] or "",
                "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
                tmp_path,
                shortcut.get("resource_key"),
            )
            body = xlsx_to_markdown(tmp_path)
        finally:
            tmp_path.unlink(missing_ok=True)
        if not body.strip():
            return None
        out_path.write_text(
            _with_frontmatter(
                path,
                shortcut,

View on GitHub (pinned to 7fe58b0b0f)

Solutions

  1. pip install 'graphifyy[office,google]' (install both extras so gws-side helpers and xlsx parsing are present)
  2. Verify the converter imports in the same interpreter: `python -c "from graphify.office import xlsx_to_markdown"` (module path per your install)
  3. If spreadsheets are out of scope, exclude .gsheet files from the scan

Example fix

# before
pip install graphifyy
graphify build .   # RuntimeError: Google Sheets export requires the office extra

# after
pip install 'graphifyy[office,google]'
graphify build .
Defensive patterns

Strategy: validation

Validate before calling

import importlib.util

office_ok = importlib.util.find_spec("openpyxl") is not None
if not office_ok:
    raise SystemExit("Google Sheets export needs the office extra: pip install 'graphifyy[office,google]'")

Try / catch

try:
    export_google_shortcut(gsheet_path, out_dir)
except RuntimeError as e:
    if "office extra" in str(e):
        raise SystemExit(f"setup error: {e}")  # install extras, don't skip silently
    raise

Prevention

When it happens

Trigger: Scanning a tree containing .gsheet files in an install without the office extra: the module-level `from graphify... import xlsx_to_markdown` was guarded, leaving the name None, and the .gsheet branch refuses to proceed with a None converter.

Common situations: pip-installing core graphify and then pointing it at a Drive-synced folder of spreadsheets; CI images built from minimal requirements; the google extra installed but office forgotten.

Related errors


AI-assisted analysis of Graphify-Labs/graphify@7fe58b0b0f (2026-08-14). Data as JSON: /api/errors/79016cbd413ec12c. Report an issue: GitHub.