run-llama/llama_index · error · ImportError

Please install yfiles_jupyter_graphs to visualize the graph:

Error message

Please install yfiles_jupyter_graphs to visualize the graph: `pip install yfiles_jupyter_graphs`

What it means

show_jupyter_graph visualizes the property graph using the yfiles_jupyter_graphs widget, which is an optional dependency not installed with llama-index-core. The method catches the ImportError from importing GraphWidget and re-raises it with an install hint.

Source

Thrown at llama-index-core/llama_index/core/graph_stores/simple_labelled.py:290

        # save to html file
        from pyvis.network import Network

        net = Network(notebook=False, directed=True)
        net.from_nx(G)
        net.write_html(name)

    def show_jupyter_graph(self) -> None:
        """
        Visualizes the graph structure of the graph store.

        NOTE: This function requires yfiles_jupyter_graphs to be installed.
        NOTE: This method exclusively works in jupyter environments.

        """
        try:
            from yfiles_jupyter_graphs import GraphWidget
        except ImportError:
            raise ImportError(
                "Please install yfiles_jupyter_graphs to visualize the graph: `pip install yfiles_jupyter_graphs`"
            )

        w = GraphWidget()
        nodes = []
        edges = []
        for node in self.graph.nodes.values():
            node_dict = {"id": node.id, "properties": {"label": node.id}}
            nodes.append(node_dict)
        for triplet in self.graph.triplets:
            edge = {
                "id": triplet[1],
                "start": triplet[0],
                "end": triplet[2],
                "properties": {"label": triplet[1]},
            }
            edges.append(edge)
        w.nodes = nodes

View on GitHub (pinned to afd0fef371)

Solutions

  1. pip install yfiles_jupyter_graphs in the same environment running the notebook.
  2. Use the dependency-free alternative: save_networkx_graph('kg.html') and open the HTML file in a browser.
  3. If installation is impossible (offline/CI), inspect the graph programmatically via store.graph.nodes and store.graph.triplets.

Example fix

# before
index.property_graph_store.show_jupyter_graph()  # ImportError

# after (option 1)
# pip install yfiles_jupyter_graphs
index.property_graph_store.show_jupyter_graph()

# after (option 2, no extra dep)
index.property_graph_store.save_networkx_graph("kg.html")
Defensive patterns

Strategy: validation

Validate before calling

def can_show_jupyter_graph() -> bool:
    try:
        import yfiles_jupyter_graphs  # noqa: F401
        return True
    except ImportError:
        return False

Try / catch

try:
    store.show_jupyter_graph()
except ImportError:
    store.save_networkx_graph("kg.html")  # dependency-free fallback

Prevention

When it happens

Trigger: Calling index.property_graph_store.show_jupyter_graph() (or PropertyGraphIndex visualization helpers) in a Jupyter notebook without yfiles_jupyter_graphs installed.

Common situations: Fresh environments where only llama-index-core (or a thin extra) was pip-installed; running outside Jupyter where the widget cannot render anyway; CI environments missing optional viz dependencies.

Related errors


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