{"record":{"id":"99b5a23dff043a46","repo":"BerriAI/litellm","slug":"91mlangfuse-not-installed-try-running-pip-inst","errorCode":null,"errorMessage":"\u001b[91mLangfuse not installed, try running 'pip install langfuse' to fix this error: {e}\\n{traceback.format_exc()}\u001b[0m","messagePattern":"\u001b\\[91mLangfuse not installed, try running 'pip install langfuse' to fix this error: (.+?)\\\\n(.+?)\u001b\\[0m","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"litellm/integrations/langfuse/langfuse.py","lineNumber":134,"sourceCode":"\n    return public_key, secret_key, resolved_host\n\n\nclass LangFuseLogger:\n    # Class variables or attributes\n    def __init__(\n        self,\n        langfuse_public_key=None,\n        langfuse_secret=None,\n        langfuse_host=None,\n        flush_interval=1,\n        allow_env_credentials: bool = True,\n    ):\n        try:\n            import langfuse\n            from langfuse import Langfuse\n        except Exception as e:\n            raise Exception(\n                f\"\\033[91mLangfuse not installed, try running 'pip install langfuse' to fix this error: {e}\\n{traceback.format_exc()}\\033[0m\"\n            )\n        self.public_key, self.secret_key, self.langfuse_host = resolve_langfuse_credentials(\n            langfuse_public_key=langfuse_public_key,\n            langfuse_secret=langfuse_secret,\n            langfuse_host=langfuse_host,\n            allow_env_credentials=allow_env_credentials,\n        )\n        if not (self.langfuse_host.startswith(\"http://\") or self.langfuse_host.startswith(\"https://\")):\n            # add http:// if unset, assume communicating over private network - e.g. render\n            self.langfuse_host = \"http://\" + self.langfuse_host\n        self.langfuse_release = os.getenv(\"LANGFUSE_RELEASE\")\n        self.langfuse_debug = os.getenv(\"LANGFUSE_DEBUG\")\n        self.langfuse_flush_interval = LangFuseLogger._get_langfuse_flush_interval(flush_interval)\n\n        if should_use_langfuse_mock():\n            self.langfuse_client = create_mock_langfuse_client()\n            self.is_mock_mode = True","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/integrations/langfuse/langfuse.py#L116-L152","documentation":"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.","triggerScenarios":"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.","commonSituations":"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'.","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"],"exampleFix":"# before\nimport litellm\nlitellm.success_callback = [\"langfuse\"]  # Exception: Langfuse not installed...\n\n# after\n# shell: pip install langfuse\nimport litellm\nlitellm.success_callback = [\"langfuse\"]","handlingStrategy":"validation","validationCode":"import importlib.util, sys\n\ndef langfuse_available() -> bool:\n    return importlib.util.find_spec(\"langfuse\") is not None\n\nif not langfuse_available():\n    print(\"Install langfuse or disable the langfuse callback\")\n    sys.exit(1)","typeGuard":null,"tryCatchPattern":"try:\n    import litellm\n    litellm.success_callback = [\"langfuse\"]\nexcept Exception as e:\n    if \"Langfuse not installed\" in str(e):\n        litellm.success_callback = []  # degrade gracefully: run without observability\n    else:\n        raise","preventionTips":["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"],"tags":["python","langfuse","dependency","observability","callback"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}