run-llama/llama_index · error · ImportError

Opik Handler is not installed. Please install it using `pip

Error message

Opik Handler is not installed. Please install it using `pip install llama-index-callbacks-opik`

What it means

Raised by create_global_handler() when eval_mode is 'opik' but llama-index-callbacks-opik is missing. Opik (Comet) tracing is an optional integration; the lazy import of opik_callback_handler is wrapped in try/except ImportError and re-raised with the install hint.

Source

Thrown at llama-index-core/llama_index/core/callbacks/global_handlers.py:141

        AgentOpsHandler.init(**eval_params)
    elif eval_mode == "literalai":
        try:
            from llama_index.callbacks.literalai import (
                literalai_callback_handler,
            )  # pants: no-infer-dep
        except ImportError:
            raise ImportError(
                "Literal AI Handler is not installed. "
                "Please install it using `pip install llama-index-callbacks-literalai`"
            )
        handler = literalai_callback_handler(**eval_params)
    elif eval_mode == "opik":
        try:
            from llama_index.callbacks.opik import (
                opik_callback_handler,
            )  # pants: no-infer-dep
        except ImportError:
            raise ImportError(
                "Opik Handler is not installed. "
                "Please install it using `pip install llama-index-callbacks-opik`"
            )
        handler = opik_callback_handler(**eval_params)
    else:
        raise ValueError(f"Eval mode {eval_mode} not supported.")

    return handler

View on GitHub (pinned to afd0fef371)

Solutions

  1. pip install llama-index-callbacks-opik
  2. Verify: python -c "from llama_index.callbacks.opik import opik_callback_handler"
  3. Configure OPIK API credentials/endpoint if you keep tracing enabled
  4. Remove the opik eval mode if unused

Example fix

# before
set_global_handler('opik')  # ImportError

# after
# pip install llama-index-callbacks-opik
set_global_handler('opik')
Defensive patterns

Strategy: validation

Validate before calling

import importlib.util
if importlib.util.find_spec('llama_index.callbacks.opik') is None:
    raise SystemExit('pip install llama-index-callbacks-opik')

Try / catch

try:
    handler = create_global_handler('opik')
except ImportError as e:
    handler = None

Prevention

When it happens

Trigger: create_global_handler('opik', ...) or set_global_handler('opik') without the package; `from llama_index.callbacks.opik import opik_callback_handler` raises ImportError.

Common situations: Adding Opik evaluation/tracing after following Comet docs in a minimal env; installing the opik SDK without the LlamaIndex bridge; stale lockfiles after integrations were split out.

Related errors


AI-assisted analysis of run-llama/llama_index@afd0fef371 (2026-08-15). Data as JSON: /api/errors/fc1cc49a42e5446a. Report an issue: GitHub.