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.
pip install tree-sitter-languagesVerified import paths — ran on the pinned version, not inferred.
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.
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`.
Evaluate migrating your projects to `tree-sitter-language-pack` or another actively maintained Tree-sitter binding. Consult their documentation for equivalent usage patterns.
Ensure your Python environment can correctly utilize pre-compiled binary wheels (e.g., compatible OS/architecture). Do not attempt to install directly from source.
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.
Ensure the package is installed using `pip install tree-sitter-languages`.
Try specifying an older version, e.g., `pip install tree-sitter-languages==1.8.0`, or consider `pip install tree-sitter-language-pack` as it is the actively maintained successor.
Always check if the result of `get_language()` or `get_parser()` is not `None` before using it, and ensure the language string is correct and supported by your installed version of `tree-sitter-languages`. For broader and updated language support, consider `tree-sitter-language-pack`.