BerriAI/litellm · error · Exception
[91mLangfuse not installed, try running 'pip install langfu
Error message
[91mLangfuse not installed, try running 'pip install langfuse' to fix this error: {e}\n{traceback.format_exc()}[0m What it means
LiteLLM's Langfuse callback could not import the 'langfuse' Python package. The import happens lazily inside LangfuseLogger.__init__, so the error only surfaces when the callback is first constructed (e.g. litellm.success_callback = ['langfuse'] or proxy startup with langfuse enabled), not at litellm install time. The message also embeds the underlying import exception and traceback, which can reveal a broken install rather than a missing package.
Source
Thrown at litellm/integrations/langfuse/langfuse.py:134
return public_key, secret_key, resolved_host
class LangFuseLogger:
# Class variables or attributes
def __init__(
self,
langfuse_public_key=None,
langfuse_secret=None,
langfuse_host=None,
flush_interval=1,
allow_env_credentials: bool = True,
):
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{traceback.format_exc()}\033[0m"
)
self.public_key, self.secret_key, self.langfuse_host = resolve_langfuse_credentials(
langfuse_public_key=langfuse_public_key,
langfuse_secret=langfuse_secret,
langfuse_host=langfuse_host,
allow_env_credentials=allow_env_credentials,
)
if not (self.langfuse_host.startswith("http://") or self.langfuse_host.startswith("https://")):
# add http:// if unset, assume communicating over private network - e.g. render
self.langfuse_host = "http://" + self.langfuse_host
self.langfuse_release = os.getenv("LANGFUSE_RELEASE")
self.langfuse_debug = os.getenv("LANGFUSE_DEBUG")
self.langfuse_flush_interval = LangFuseLogger._get_langfuse_flush_interval(flush_interval)
if should_use_langfuse_mock():
self.langfuse_client = create_mock_langfuse_client()
self.is_mock_mode = TrueView on GitHub (pinned to 6c2dcb801b)
Solutions
- pip install langfuse (or pip install 'litellm[langfuse]' if using extras)
- Run python -c 'import langfuse' and read the embedded traceback in the error message — if the package IS installed, fix the underlying import failure (commonly a pydantic version conflict) instead of reinstalling
- Pin compatible versions, e.g. pip install -U langfuse pydantic, then retry
- If you do not need Langfuse, remove it from success_callback / proxy litellm_settings
Example fix
# before import litellm litellm.success_callback = ["langfuse"] # Exception: Langfuse not installed... # after # shell: pip install langfuse import litellm litellm.success_callback = ["langfuse"]
Defensive patterns
Strategy: validation
Validate before calling
import importlib.util, sys
def langfuse_available() -> bool:
return importlib.util.find_spec("langfuse") is not None
if not langfuse_available():
print("Install langfuse or disable the langfuse callback")
sys.exit(1) Try / catch
try:
import litellm
litellm.success_callback = ["langfuse"]
except Exception as e:
if "Langfuse not installed" in str(e):
litellm.success_callback = [] # degrade gracefully: run without observability
else:
raise Prevention
- Install optional observability extras in the same commit that enables the callback
- Add a 'python -c import langfuse' preflight check to CI for services using langfuse callbacks
- Pin langfuse and pydantic versions to avoid import-time breakage
When it happens
Trigger: Setting litellm.success_callback = ['langfuse'] (or defining langfuse callback params in the proxy config) without 'pip install langfuse'; installing a langfuse version whose transitive deps fail to import (e.g. incompatible pydantic); a corrupted venv where 'import langfuse' raises any Exception.
Common situations: Using litellm's optional observability integrations — langfuse is an optional extra, so a plain 'pip install litellm' lacks it. Also seen after upgrading pydantic/langfuse to incompatible versions, where the import itself throws and is misreported as 'not installed'.
Related errors
- Max langfuse clients reached: {litellm.initialized_langfuse_
- [91mLangfuse not installed, try running 'pip install langfu
- LANGFUSE_PUBLIC_KEY and LANGFUSE_SECRET_KEY must be set for
- prompt_id is required for Langfuse prompt management
- Error logging request payload. Payload=none.
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/99b5a23dff043a46.
Report an issue: GitHub.