{"id":3253,"library":"pyvis","title":"Pyvis Network Visualization Library","description":"Pyvis is a Python library designed for the quick generation of interactive network graphs with minimal Python code. It acts as a wrapper around the popular JavaScript Vis.js library, enabling users to build graphs in Python, customize nodes and edges with various properties, and export them as interactive HTML files. The library is currently at version 0.3.2 and maintains an active development status with regular updates, including a significant 0.3.0 release that merged an experimental branch and added features like node/edge filtering from the web interface.","status":"active","version":"0.3.2","language":"en","source_language":"en","source_url":"https://github.com/WestHealth/pyvis","tags":["visualization","graph","network","interactive","jupyter"],"install":[{"cmd":"pip install pyvis","lang":"bash","label":"Install Pyvis"}],"dependencies":[{"reason":"Often used for graph creation and algorithms, with Pyvis providing visualization via its `from_nx` method.","package":"networkx","optional":false},{"reason":"Used for templating the HTML output.","package":"jinja2","optional":false},{"reason":"Provides richer output and integration for Jupyter environments.","package":"ipython","optional":true},{"reason":"Handles serialization of complex Python objects to JSON, used internally.","package":"jsonpickle","optional":false}],"imports":[{"symbol":"Network","correct":"from pyvis.network import Network"}],"quickstart":{"code":"from pyvis.network import Network\n\n# Create a Network object\nnet = Network(height=\"750px\", width=\"100%\", bgcolor=\"#222222\", font_color=\"white\", notebook=False)\n\n# Add nodes\nnet.add_node(1, label=\"Node 1\", title=\"This is node 1\")\nnet.add_node(2, label=\"Node 2\", title=\"This is node 2\", color=\"#00ff1e\")\nnet.add_node(3, label=\"Node 3\", title=\"This is node 3\")\n\n# Add edges\nnet.add_edge(1, 2, title=\"connects 1 and 2\")\nnet.add_edge(2, 3, title=\"connects 2 and 3\", value=5)\n\n# Generate and save the network visualization to an HTML file\nnet.show(\"basic_network.html\")","lang":"python","description":"This quickstart demonstrates how to create a basic interactive network graph using Pyvis. It initializes a `Network` object, adds three nodes with custom labels, titles, and colors, then connects them with edges. Finally, it generates an HTML file (`basic_network.html`) that can be opened in a browser to interact with the visualization. The `notebook=False` parameter ensures it generates a standalone HTML file."},"warnings":[{"fix":"Assign unique integer or string IDs to each node using `net.add_node(id, ...)` or ensure lists passed to `net.add_nodes()` contain unique identifiers.","message":"Node IDs must be unique within a network. Re-adding a node with an existing ID will overwrite its properties, not create a new node. Ensure uniqueness for proper graph structure.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Consult both the Pyvis documentation (specifically `network.Network.add_node()` and `network.Network.add_edge()` docs) and the original VisJS documentation for supported attributes and their Python equivalents. Experimentation may be required.","message":"Some attributes from the underlying VisJS library may not work as expected or at all when accessed via Pyvis. This is due to direct Python translation limitations.","severity":"gotcha","affected_versions":"All versions"},{"fix":"After interactively adjusting settings via `show_buttons()`, use the 'generate options' button in the UI to copy the JSON configuration. Then, pass this JSON string to `net.set_options(json_string)` in your Python script to save the desired layout and interaction configurations.","message":"When using `net.show_buttons(filter_menu=True, select_menu=True, ...)` to interactively tweak layout or filtering settings in the browser, these changes are not automatically saved to your Python code. To persist interactive settings, you need to copy the generated options from the browser UI and apply them to your `Network` object using `net.set_options()`.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Leverage NetworkX for graph creation, manipulation, and analysis. Integrate Pyvis at the visualization stage by converting your NetworkX graph into a Pyvis network using `net.from_nx()`.","message":"Pyvis is primarily a visualization tool and is not as robust as libraries like NetworkX for complex graph analysis or generating network metrics (e.g., centrality). For advanced graph algorithms, it's recommended to build and analyze your graph with NetworkX first, then pass the NetworkX graph to Pyvis for visualization using `net.from_nx(nx_graph)`.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}