Graphify-Labs/graphify · error · ImportError
tree-sitter is not installed. Run: pip install 'tree-sitter>
Error message
tree-sitter is not installed. Run: pip install 'tree-sitter>=0.23.0'
What it means
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).
Source
Thrown at graphify/extract.py:3897
if unit_elem is not None:
unit_name = unit_elem.get("Value", "")
if unit_name:
unit_nid = _pascal_resolve_unit(path, unit_name)
add_node(unit_nid, unit_name)
add_edge(pkg_nid, unit_nid, "contains")
return {"nodes": nodes, "edges": edges, "input_tokens": 0, "output_tokens": 0}
# ── Main extract and collect_files ────────────────────────────────────────────
def _check_tree_sitter_version() -> None:
"""Raise a clear error if tree-sitter is too old for the new Language API."""
try:
from tree_sitter import LANGUAGE_VERSION
except ImportError:
raise ImportError(
"tree-sitter is not installed. Run: pip install 'tree-sitter>=0.23.0'"
)
# Language API v2 starts at LANGUAGE_VERSION 14
if LANGUAGE_VERSION < 14:
import tree_sitter as _ts
raise RuntimeError(
f"tree-sitter {getattr(_ts, '__version__', 'unknown')} is too old. "
f"graphify requires tree-sitter >= 0.23.0 (Language API v2). "
f"Run: pip install --upgrade tree-sitter"
)
# ── .NET project files (.sln, .slnx, .csproj, .razor) ───────────────────────
def extract_slnx(path: Path) -> dict:
"""Extract projects and inter-project dependencies from a .slnx file.
View on GitHub (pinned to 7fe58b0b0f)
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
Example fix
# before graphify build . # ImportError: tree-sitter is not installed # after pip install 'tree-sitter>=0.23.0' graphify build .
Defensive patterns
Strategy: validation
Validate before calling
import importlib.util
if importlib.util.find_spec("tree_sitter") is None:
raise SystemExit("tree-sitter missing: pip install 'tree-sitter>=0.23.0'")
from graphify.extract import collect_files # extraction now safe to run Try / catch
try:
from graphify.extract import extract
result = extract(paths)
except ImportError as e:
if "tree-sitter" in str(e):
raise SystemExit(f"setup error: {e}")
raise Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- tree-sitter {getattr(_ts, '__version__', 'unknown')} is too
- matplotlib not installed. Run: pip install matplotlib
- neo4j driver not installed. Run: pip install neo4j
- falkordb SDK not installed. Run: pip install falkordb
- the '{pkg}' package is required for this backend but is not
AI-assisted analysis of Graphify-Labs/graphify@7fe58b0b0f (2026-08-14).
Data as JSON: /api/errors/4150b059b3d8e910.
Report an issue: GitHub.