Registry / data / pyvis
library0.3.2pypypi✓ verified 26d ago

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.

pip install pyvis
INSTALL
IMPORT
SIG · PYVIS
P
pyvis
datapythonv0.3.2
Install
6.5s avg
Import
1126ms
Disk
94MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v0.3.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 1.210s · 99.9MB
glibc
py 3.10–3.95 runs
installs and imports cleanly · install 6.5s · import 1.042s · 100MB
94MB installed
● package 94MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Network
✓ from pyvis.network import Network

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.

from pyvis.network import Network # Create a Network object net = Network(height="750px", width="100%", bgcolor="#222222", font_color="white", notebook=False) # Add nodes net.add_node(1, label="Node 1", title="This is node 1") net.add_node(2, label="Node 2", title="This is node 2", color="#00ff1e") net.add_node(3, label="Node 3", title="This is node 3") # Add edges net.add_edge(1, 2, title="connects 1 and 2") net.add_edge(2, 3, title="connects 2 and 3", value=5) # Generate and save the network visualization to an HTML file net.show("basic_network.html")
Debug
Known issues
gotchaNode 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.
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.
affects: All versions
gotchaSome 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.
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.
affects: All versions
gotchaWhen 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()`.
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.
affects: All versions
gotchaPyvis 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)`.
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()`.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'pyvis'
The pyvis library has not been installed in the current Python environment or the environment is not correctly activated.
fix
Install the library using pip: `pip install pyvis`
NameError: name 'Network' is not defined
The 'Network' class, which is used to create graph objects, has not been imported from the 'pyvis.network' module.
fix
Add the import statement at the beginning of your script: `from pyvis.network import Network`
KeyError: 'group'
This error occurs when a node is assigned a 'group' property without that group being defined within the network's options configuration.
fix
Define the group and its properties within the network options, for example: `net.set_options({'groups': {'my_group': {'color': 'red'}}})` before adding nodes with that group.
AttributeError: 'Network' object has no attribute 'from_dataframe'
Pyvis does not inherently provide a 'from_dataframe' method to directly construct graphs from Pandas DataFrames, unlike some other graph visualization libraries.
fix
Manually iterate through your DataFrame to extract node and edge data, then add them to the 'Network' object using `net.add_node()` and `net.add_edge()`.
Upgrade
Version history
0.3.2latest on PyPI · released Feb 24, 2023
Audit
Dependencies
networkxrequiredOften used for graph creation and algorithms, with Pyvis providing visualization via its `from_nx` method.
jinja2requiredUsed for templating the HTML output.
ipythonoptionalProvides richer output and integration for Jupyter environments.
jsonpicklerequiredHandles serialization of complex Python objects to JSON, used internally.
Agent activity
31 hits · last 30 days
node
18
Amazon
1
Resources