{"id":5733,"library":"tree-sitter-languages","title":"tree-sitter-languages","description":"The `tree-sitter-languages` library provides pre-compiled binary Python wheels for various Tree-sitter language parsers. It simplifies the setup for `py-tree-sitter` users by bundling common language grammars, eliminating the need for manual compilation. As of its last updates, the library is largely unmaintained, with official recommendations to consider `tree-sitter-language-pack` for active development and broader compatibility.","status":"deprecated","version":"1.10.2","language":"en","source_language":"en","source_url":"https://github.com/grantjenks/py-tree-sitter-languages","tags":["tree-sitter","parsing","syntax-tree","language-parsers","binary-wheels"],"install":[{"cmd":"pip install tree-sitter-languages","lang":"bash","label":"PyPI"}],"dependencies":[{"reason":"Provides the core Tree-sitter Python bindings; specific versions are required for compatibility.","package":"tree-sitter"}],"imports":[{"symbol":"get_language","correct":"from tree_sitter_languages import get_language"},{"symbol":"get_parser","correct":"from tree_sitter_languages import get_parser"}],"quickstart":{"code":"from tree_sitter_languages import get_language, get_parser\nimport tree_sitter # The underlying tree-sitter library\n\n# IMPORTANT: This library has known compatibility issues with newer versions of `tree-sitter`.\n# For versions of `tree-sitter-languages` up to 1.10.2, you might need to pin `tree-sitter`\n# to an earlier version for functionality, e.g., `pip install tree-sitter==0.21.3`.\n\ntry:\n    # Get a language object for Python\n    python_language = get_language('python')\n    print(f\"Loaded language: {python_language}\")\n\n    # Get a parser instance for Python\n    python_parser = get_parser('python')\n    print(f\"Created parser: {python_parser}\")\n\n    # Example usage: parse some Python code\n    code_bytes = b\"\"\"\n    def hello_world():\n        print('Hello, Tree-sitter!')\n    \"\"\"\n    tree = python_parser.parse(code_bytes)\n    \n    print(\"\\nParsed code:\")\n    print(code_bytes.decode())\n    print(\"\\nRoot node of the syntax tree (S-expression form):\")\n    print(tree.root_node.sexp())\n\nexcept ImportError as e:\n    print(f\"Error: {e}. Ensure 'tree-sitter-languages' and 'tree-sitter' are installed.\")\nexcept Exception as e:\n    print(f\"An error occurred during parsing: {e}. Check tree-sitter version compatibility.\")\n","lang":"python","description":"Demonstrates how to load a language and obtain a parser, then use it to parse a simple Python code snippet. It highlights the crucial dependency on `tree-sitter` and the potential need for version pinning."},"warnings":[{"fix":"Pin `tree-sitter` to an earlier, compatible version, such as `0.21.3`, when installing: `pip install tree-sitter-languages tree-sitter==0.21.3`.","message":"Versions of `tree-sitter` equal to or greater than `0.22` (especially `0.25.1` and higher) introduce breaking changes that are incompatible with `tree-sitter-languages`. Attempting to use newer `tree-sitter` versions will result in runtime errors.","severity":"breaking","affected_versions":"tree-sitter-languages all versions (when used with tree-sitter >= 0.22)"},{"fix":"Evaluate migrating your projects to `tree-sitter-language-pack` or another actively maintained Tree-sitter binding. Consult their documentation for equivalent usage patterns.","message":"The `tree-sitter-languages` library is largely unmaintained. The original maintainers recommend migrating to `tree-sitter-language-pack` for continued support, new features, and broader compatibility with modern `tree-sitter` versions.","severity":"deprecated","affected_versions":"All versions"},{"fix":"Ensure your Python environment can correctly utilize pre-compiled binary wheels (e.g., compatible OS/architecture). Do not attempt to install directly from source.","message":"Source installs of `tree-sitter-languages` are not supported. The library is distributed exclusively as pre-compiled binary wheels. Attempts to install from source will fail.","severity":"gotcha","affected_versions":"All versions"},{"fix":"After obtaining a `language` or `parser` object, refer to the `py-tree-sitter` documentation for its API to perform detailed parsing, analysis, and manipulation tasks.","message":"The API provided by `tree-sitter-languages` is extremely minimal, offering only `get_language` and `get_parser`. For any advanced operations, such as traversing the syntax tree, querying nodes, or modifying parsers, you must directly interact with the underlying `py-tree-sitter` library's API.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-03-28T00:00:00.000Z","next_check":"2026-06-26T00:00:00.000Z"}