BerriAI/litellm · error · Exception

Langfuse not installed, try running 'pip install langfu

Error message

Langfuse not installed, try running 'pip install langfuse' to fix this error: {e}\n

What it means

Same missing-dependency guard as the main Langfuse logger, but in the prompt-management helper (langfuse_client_init). It lazily imports 'langfuse' when LiteLLM needs to fetch a managed prompt, and wraps any import failure in this message. It surfaces when you configure Langfuse as the prompt manager, not at litellm install time.

Source

Thrown at litellm/integrations/langfuse/langfuse_prompt_management.py:69

    Initialize Langfuse client with caching to prevent multiple initializations.

    Args:
        langfuse_public_key (str, optional): Public key for Langfuse. Defaults to None.
        langfuse_secret (str, optional): Secret key for Langfuse. Defaults to None.
        langfuse_host (str, optional): Host URL for Langfuse. Defaults to None.
        flush_interval (int, optional): Flush interval in seconds. Defaults to 1.

    Returns:
        Langfuse: Initialized Langfuse client instance

    Raises:
        Exception: If langfuse package is not installed
    """
    try:
        import langfuse
        from langfuse import Langfuse
    except Exception as e:
        raise Exception(
            f"\033[91mLangfuse not installed, try running 'pip install langfuse' to fix this error: {e}\n\033[0m"
        )

    public_key, secret_key, langfuse_host = resolve_langfuse_credentials(
        langfuse_public_key=langfuse_public_key,
        langfuse_secret=langfuse_secret,
        langfuse_secret_key=langfuse_secret_key,
        langfuse_host=langfuse_host,
        allow_env_credentials=allow_env_credentials,
    )

    if not (langfuse_host.startswith("http://") or langfuse_host.startswith("https://")):
        # add http:// if unset, assume communicating over private network - e.g. render
        langfuse_host = "http://" + langfuse_host

    langfuse_release: Final = os.getenv("LANGFUSE_RELEASE")
    langfuse_debug: Final = os.getenv("LANGFUSE_DEBUG")

View on GitHub (pinned to 6c2dcb801b)

Solutions

  1. pip install langfuse
  2. Verify with python -c 'import langfuse'; if it fails despite being installed, fix the underlying import error shown in the message (typically dependency version conflicts)
  3. Reinstall cleanly if the venv is corrupted: pip install --force-reinstall langfuse
  4. Drop the langfuse prompt manager config if prompt management is not actually needed

Example fix

# before
import litellm
litellm.prompt_manager = ["langfuse"]  # Exception: Langfuse not installed...

# after
# shell: pip install langfuse
import litellm
litellm.prompt_manager = ["langfuse"]
Defensive patterns

Strategy: validation

Validate before calling

import importlib.util

if importlib.util.find_spec("langfuse") is None:
    raise RuntimeError("langfuse package required for prompt management; pip install langfuse")

Prevention

When it happens

Trigger: Setting litellm.prompt_manager = 'langfuse' (or passing a langfuse prompt spec via callbacks) without the langfuse package installed; a broken langfuse install whose import raises due to a dependency conflict.

Common situations: Adopting LiteLLM's unified prompt management against Langfuse while only having installed the core litellm package; upgrading pydantic breaks the installed langfuse's imports, which is misread as 'not installed'.

Related errors


AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15). Data as JSON: /api/errors/06a13fb123cb6883. Report an issue: GitHub.