Lightning-AI/pytorch-lightning · error · ModuleNotFoundError

{_JSONARGPARSE_SIGNATURES_AVAILABLE}

Error message

{_JSONARGPARSE_SIGNATURES_AVAILABLE}

What it means

LightningCLI relies on jsonargparse's signatures feature (added in jsonargparse 4.x, APIs v4.5.0+). On init it checks _JSONARGPARSE_SIGNATURES_AVAILABLE; if the installed jsonargparse is too old (or the feature import failed), it raises ModuleNotFoundError with the stored reason string.

Source

Thrown at src/lightning/pytorch/cli.py:116

        *args: Any,
        description: str = "Lightning Trainer command line tool",
        env_prefix: str = "PL",
        default_env: bool = False,
        **kwargs: Any,
    ) -> None:
        """Initialize argument parser that supports configuration file input.

        For full details of accepted arguments see `ArgumentParser.__init__
        <https://jsonargparse.readthedocs.io/en/stable/#jsonargparse.ArgumentParser.__init__>`_.

        Args:
            description: Description of the tool shown when running ``--help``.
            env_prefix: Prefix for environment variables. Set ``default_env=True`` to enable env parsing.
            default_env: Whether to parse environment variables.

        """
        if not _JSONARGPARSE_SIGNATURES_AVAILABLE:
            raise ModuleNotFoundError(f"{_JSONARGPARSE_SIGNATURES_AVAILABLE}")
        super().__init__(*args, description=description, env_prefix=env_prefix, default_env=default_env, **kwargs)
        self.callback_keys: list[str] = []
        # separate optimizers and lr schedulers to know which were added
        self._optimizers: dict[str, tuple[Union[type, tuple[type, ...]], str]] = {}
        self._lr_schedulers: dict[str, tuple[Union[type, tuple[type, ...]], str]] = {}

    def add_lightning_class_args(
        self,
        lightning_class: Union[
            Callable[..., Union[Trainer, LightningModule, LightningDataModule, Callback]],
            type[Trainer],
            type[LightningModule],
            type[LightningDataModule],
            type[Callback],
        ],
        nested_key: str,
        subclass_mode: bool = False,
        required: bool = True,

View on GitHub (pinned to 9fed5c27d2)

Solutions

  1. pip install -U jsonargparse[signatures] (>= 4.5.0 / latest)
  2. Check the actual reason: python -c "import jsonargparse; print(jsonargparse.__version__)" and inspect _JSONARGPARSE_SIGNATURES_AVAILABLE in lightning.pytorch.cli
  3. Recreate the environment if the pin comes from another package

Example fix

# before
# jsonargparse 3.x installed -> ModuleNotFoundError from LightningCLI
# after
pip install -U "jsonargparse[signatures]"
cli = LightningCLI(MyModule)
Defensive patterns

Strategy: validation

Validate before calling

import jsonargparse
from packaging.version import Version
assert Version(jsonargparse.__version__) >= Version('4.5.0'), 'run: pip install -U "jsonargparse[signatures]"'

Prevention

When it happens

Trigger: pip install lightning-cli / lightning in an environment that already pins jsonargparse<4 (or a broken install), then running LightningCLI(...).

Common situations: Dependency conflicts where another package pins an old jsonargparse; stale conda environments after upgrading lightning.

Related errors


AI-assisted analysis of Lightning-AI/pytorch-lightning@9fed5c27d2 (2026-08-28). Data as JSON: /api/errors/dfe05da512931b3f. Report an issue: GitHub.