{"record":{"id":"4150b059b3d8e910","repo":"Graphify-Labs/graphify","slug":"tree-sitter-is-not-installed-run-pip-install-tr","errorCode":null,"errorMessage":"tree-sitter is not installed. Run: pip install 'tree-sitter>=0.23.0'","messagePattern":"tree-sitter is not installed\\. Run: pip install 'tree-sitter>=0\\.23\\.0'","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"graphify/extract.py","lineNumber":3897,"sourceCode":"        if unit_elem is not None:\n            unit_name = unit_elem.get(\"Value\", \"\")\n            if unit_name:\n                unit_nid = _pascal_resolve_unit(path, unit_name)\n                add_node(unit_nid, unit_name)\n                add_edge(pkg_nid, unit_nid, \"contains\")\n\n    return {\"nodes\": nodes, \"edges\": edges, \"input_tokens\": 0, \"output_tokens\": 0}\n\n\n# ── Main extract and collect_files ────────────────────────────────────────────\n\n\ndef _check_tree_sitter_version() -> None:\n    \"\"\"Raise a clear error if tree-sitter is too old for the new Language API.\"\"\"\n    try:\n        from tree_sitter import LANGUAGE_VERSION\n    except ImportError:\n        raise ImportError(\n            \"tree-sitter is not installed. Run: pip install 'tree-sitter>=0.23.0'\"\n        )\n    # Language API v2 starts at LANGUAGE_VERSION 14\n    if LANGUAGE_VERSION < 14:\n        import tree_sitter as _ts\n        raise RuntimeError(\n            f\"tree-sitter {getattr(_ts, '__version__', 'unknown')} is too old. \"\n            f\"graphify requires tree-sitter >= 0.23.0 (Language API v2). \"\n            f\"Run: pip install --upgrade tree-sitter\"\n        )\n\n\n# ── .NET project files (.sln, .slnx, .csproj, .razor) ───────────────────────\n\n\ndef extract_slnx(path: Path) -> dict:\n    \"\"\"Extract projects and inter-project dependencies from a .slnx file.\n","sourceCodeStart":3879,"sourceCodeEnd":3915,"githubUrl":"https://github.com/Graphify-Labs/graphify/blob/7fe58b0b0f3873be9a21c30106b8b8527c353aa6/graphify/extract.py#L3879-L3915","documentation":"Raised by graphify's extractor bootstrap (_check_tree_sitter_version) when the `tree_sitter` module cannot be imported at all. graphify uses tree-sitter's Language API v2 for AST parsing of source files; the probe imports LANGUAGE_VERSION as the cheapest check and converts a bare ImportError into a message pinning the minimum version (>= 0.23.0).","triggerScenarios":"Any extraction run over source code files (the main graphify build path) in an environment where `from tree_sitter import LANGUAGE_VERSION` raises ImportError — i.e. tree-sitter was never installed in the active interpreter.","commonSituations":"Installing graphify from a source checkout without its parsing extras; mixing interpreters (pip installed into system Python but graphify runs under a uv/pipx venv); a venv recreated without regenerating requirements.","solutions":["pip install 'tree-sitter>=0.23.0'","If it still fails, confirm which interpreter runs graphify: `graphify --version` vs `python -m graphify ...`, and install into that interpreter","For locked environments: `uv pip install 'tree-sitter>=0.23.0'` or add it to the project's dependencies and sync"],"exampleFix":"# before\ngraphify build .   # ImportError: tree-sitter is not installed\n\n# after\npip install 'tree-sitter>=0.23.0'\ngraphify build .","handlingStrategy":"validation","validationCode":"import importlib.util\n\nif importlib.util.find_spec(\"tree_sitter\") is None:\n    raise SystemExit(\"tree-sitter missing: pip install 'tree-sitter>=0.23.0'\")\n\nfrom graphify.extract import collect_files  # extraction now safe to run","typeGuard":null,"tryCatchPattern":"try:\n    from graphify.extract import extract\n    result = extract(paths)\nexcept ImportError as e:\n    if \"tree-sitter\" in str(e):\n        raise SystemExit(f\"setup error: {e}\")\n    raise","preventionTips":["Pin 'tree-sitter>=0.23.0' in your requirements alongside graphify","After any venv rebuild, smoke-test with `python -c \"from tree_sitter import LANGUAGE_VERSION\"`","Run graphify via `python -m graphify` when unsure which interpreter is active"],"tags":["dependency","tree-sitter","parsing","import-error","version-check"],"backgroundTag":null,"analyzedSha":"7fe58b0b0f3873be9a21c30106b8b8527c353aa6","analyzedAt":"2026-08-14T19:23:21.323Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}