Installation

On this page

Requirements

  • Python 3.9+ (the codebase uses from __future__ import annotations, PEP 604-style optional typing via Optional[...], and tuple[Any, str] built-in generics in base_parser.py, which requires Python 3.9+ at minimum and 3.10+ for some annotations to evaluate eagerly without the future import).
  • No hard runtime dependencies for the core parsing logic — the standard library (json, csv, re, io, hashlib, logging) covers JSON, CSV, list, key-value, XML, and tool-call parsing.

Optional dependencies

Two features are gated behind optional imports and degrade gracefully when the dependency is missing:

DependencyEnablesBehavior if missing
pydanticAnswerSchema, ToolCallSchema, RetrievalResultSchema, RankedAnswersSchema (typed schemas in schema.py); PydanticOutputParser; Pydantic-based get_format_instructions() in JSONOutputParser/YAMLOutputParserschema.py falls back to plain @dataclass equivalents of the four schema classes (PYDANTIC_AVAILABLE = False). PydanticOutputParser.__init__ and JSONOutputParser._validate_pydantic_model raise ImportError if you try to use them without pydantic installed.
PyYAML (yaml)YAMLOutputParser, OutputFormat.YAML handling inside OutputParser's pipeline (_parse_yaml in parser.py)YAMLOutputParser.__init__ raises ImportError immediately. Inside the orchestrator, _parse_yaml raises ImportError("pyyaml not installed") when a YAML-formatted output is detected.

Install with the extras you need:

Bash
pip install pydantic pyyaml

Installing the package

[!WARNING] Package distribution not determinable from source The uploaded source tree contains only the output_parser/ package directory (14 .py files) — there is no pyproject.toml, setup.py, or setup.cfg in the archive that was analyzed. This documentation cannot state a PyPI package name, version, or pip install output_parser-style command with certainty. If this module lives inside a larger monorepo (e.g. a rag package, based on the docstring in parser.py referring to "the RAG Output Parser module"), install it the same way you install the rest of that project — for example with an editable install:

Bash
pip install -e .

from the repository root, or by adding the containing package to your PYTHONPATH.

Verifying the install

Python · 5 lines
from output_parser import OutputParser, JSONOutputParser

parser = OutputParser()
print(parser.parse('{"answer": "ok"}').data)
# {'answer': 'ok'}

If this runs without an ImportError, the core package is installed correctly. To verify optional dependencies:

Python · 5 lines
from output_parser.schema import PYDANTIC_AVAILABLE
from output_parser.yaml_parser import YAML_AVAILABLE

print("pydantic:", PYDANTIC_AVAILABLE)
print("pyyaml:", YAML_AVAILABLE)

Next: Quickstart.

Related pages