{"record":{"id":"fcefc06a6d4f5a80","repo":"deepset-ai/haystack","slug":"this-method-is-only-supported-in-jupyter-notebooks","errorCode":null,"errorMessage":"This method is only supported in Jupyter notebooks. Use Pipeline.draw() to save an image locally.","messagePattern":"This method is only supported in Jupyter notebooks\\. Use Pipeline\\.draw\\(\\) to save an image locally\\.","errorType":"exception","errorClass":"PipelineDrawingError","httpStatus":null,"severity":"error","filePath":"haystack/core/pipeline/base.py","lineNumber":961,"sourceCode":"            from IPython.display import Image, display\n\n            if super_component_expansion:\n                graph, super_component_mapping = self._merge_super_component_pipelines()\n            else:\n                graph = self.graph\n                super_component_mapping = None\n\n            image_data = _to_mermaid_image(\n                graph,\n                server_url=server_url,\n                params=params,\n                timeout=timeout,\n                super_component_mapping=super_component_mapping,\n            )\n            display(Image(image_data))\n        else:\n            msg = \"This method is only supported in Jupyter notebooks. Use Pipeline.draw() to save an image locally.\"\n            raise PipelineDrawingError(msg)\n\n    def draw(\n        self,\n        *,\n        path: Path,\n        server_url: str = \"https://mermaid.ink\",\n        params: dict | None = None,\n        timeout: int = 30,\n        super_component_expansion: bool = False,\n    ) -> None:\n        \"\"\"\n        Save an image representing this `Pipeline` to the specified file path.\n\n        This function generates a diagram of the `Pipeline` using the Mermaid server and saves it to the provided path.\n\n        :param path:\n            The file path where the generated image will be saved.\n","sourceCodeStart":943,"sourceCodeEnd":979,"githubUrl":"https://github.com/deepset-ai/haystack/blob/e318778c9bf60a1963e3b5f451359655dd696c30/haystack/core/pipeline/base.py#L943-L979","documentation":"Pipeline.show() raises PipelineDrawingError when called outside a Jupyter notebook. show() renders the pipeline image inline via IPython's display(); outside Jupyter there is no display hook, so you must use Pipeline.draw(path=...) to save the image to a file instead.","triggerScenarios":"Calling pipeline.show() in a plain Python script, REPL, or web backend; running in Jupyter without IPython display available (get_ipython() returns None).","commonSituations":"Porting notebook code into a script or service; CI pipelines running notebook logic headlessly; missing IPython installation in the environment.","solutions":["Replace show() with pipeline.draw(path='pipeline.png') to save to a file","If in Jupyter, ensure IPython is installed and the kernel is running so get_ipython() returns a shell","In scripts, open the saved image after draw() if you need to view it"],"exampleFix":"// before\npipeline.show()  # in a script\n// after\npipeline.draw(path='pipeline.png')","handlingStrategy":"fallback","validationCode":"def in_jupyter() -> bool:\n    try:\n        return get_ipython() is not None  # noqa: F821\n    except NameError:\n        return False\nassert in_jupyter(), 'Use pipeline.draw(path=...) outside Jupyter'","typeGuard":"def supports_show() -> bool:\n    try:\n        import ipykernel  # noqa: F401\n        return get_ipython() is not None  # noqa: F821\n    except Exception:\n        return False","tryCatchPattern":"try:\n    pipeline.show()\nexcept PipelineDrawingError:\n    pipeline.draw(path='pipeline.png')","preventionTips":["Use draw(path=...) in scripts, services and CI","Reserve show() for interactive notebooks","Gate show() behind an is-notebook check in shared utilities"],"tags":["pipeline","haystack","jupyter","drawing"],"backgroundTag":"jupyter-only-api","analyzedSha":"e318778c9bf60a1963e3b5f451359655dd696c30","analyzedAt":"2026-08-30T11:45:20.711Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}