{"id":9836,"library":"ipycytoscape","title":"Interactive Cytoscape Widget for Jupyter","description":"ipycytoscape is a Python library that provides a Cytoscape widget for Jupyter notebooks and JupyterLab environments. It allows users to visualize and interact with complex networks directly within their Jupyter workflows, leveraging the powerful rendering capabilities of Cytoscape.js. The current version is 1.3.3, with minor releases occurring every few months for bug fixes and compatibility updates.","status":"active","version":"1.3.3","language":"en","source_language":"en","source_url":"https://github.com/cytoscape/ipycytoscape","tags":["jupyter","widget","cytoscape","graph","networkx","visualization"],"install":[{"cmd":"pip install ipycytoscape","lang":"bash","label":"Install ipycytoscape"}],"dependencies":[{"reason":"Used in examples for integrating with Neo4j graphs, but not a core dependency.","package":"py2neo","optional":true}],"imports":[{"symbol":"CytoscapeWidget","correct":"from ipycytoscape import CytoscapeWidget"}],"quickstart":{"code":"import ipycytoscape\nimport networkx as nx\n\n# Create a Cytoscape widget instance\ncy = ipycytoscape.CytoscapeWidget()\n\n# Create a simple graph using NetworkX\nG = nx.Graph()\nG.add_edge('A', 'B')\nG.add_edge('B', 'C')\nG.add_node('D')\n\n# Add the graph data to the widget\ncy.graph.add_graph_from_networkx(G, directed=False)\n\n# Set a layout; this is crucial for the graph to display properly\ncy.set_layout(name='cose') # Other options: 'cola', 'grid', 'circle', etc.\n\n# Display the widget\ncy\n","lang":"python","description":"This quickstart demonstrates how to create a Cytoscape widget, populate it with data from a NetworkX graph, apply a layout, and display it in a Jupyter environment. The `set_layout()` call is essential for proper rendering."},"warnings":[{"fix":"Ensure you are using `ipycytoscape>=1.2.0` for JupyterLab 3+ compatibility without a build step. If upgrading from an older version, remove any manual `jupyter lab build` steps from your workflow. Consider `pip install --upgrade ipycytoscape`.","message":"Version 1.2.0 significantly changed how ipycytoscape integrates with JupyterLab. Prior to 1.2.0, an explicit `jupyter lab build` step and Node.js were often required. Version 1.2.0+ no longer requires these for JupyterLab 3 and above.","severity":"breaking","affected_versions":"<1.2.0 to 1.2.0+"},{"fix":"Always call `cy.set_layout(name='some_layout_name')` after adding graph data to the widget. Common layout names include 'cola', 'cose', 'grid', 'circle', 'random'.","message":"Graphs may not display properly (nodes overlapping at the center) if a layout is not explicitly set using `cy.set_layout()`. Cytoscape.js requires a layout algorithm to arrange nodes and edges.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Run `jupyter nbextension enable --py --sys-prefix ipycytoscape` from your terminal if widgets fail to load in classic Jupyter Notebook.","message":"When using `ipycytoscape` in classic Jupyter Notebook (not JupyterLab), you might need to ensure the nbextension is enabled, especially if the widget does not render.","severity":"gotcha","affected_versions":"All versions (less common with recent JupyterLab)"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"For JupyterLab 3+, ensure `ipycytoscape>=1.2.0` is installed. No manual build should be needed. For classic Notebook, try `jupyter nbextension enable --py --sys-prefix ipycytoscape`. Restart your kernel and browser.","cause":"The Jupyter environment (JupyterLab or classic Notebook) has not correctly loaded the ipycytoscape frontend extension.","error":"Widget not found. This usually happens when the widgets JavaScript hasn't been run."},{"fix":"Use the `set_layout` method with the `name` parameter, e.g., `cy.set_layout(name='cola')`. If you need custom layout options, provide a dictionary: `cy.set_layout(name='cose', options={'padding': 10})`.","cause":"You passed a string directly to `cy.layout` instead of using the `set_layout` method, or the `set_layout` method was used with an invalid parameter type.","error":"TraitError: The 'layout' trait of a CytoscapeWidget instance must be a dict or None, but a value of type <class 'str'> was specified."},{"fix":"Install the package: `pip install ipycytoscape`. Ensure you are installing into the correct Python environment if you use virtual environments or conda environments.","cause":"The `ipycytoscape` package is not installed in the Python environment where Jupyter is running.","error":"ModuleNotFoundError: No module named 'ipycytoscape'"}]}