Registry / data / networkx

networkx

JSON →
library3.6.1pypypi✓ verified 24d ago

NetworkX is a Python package for creating and manipulating graphs and networks. The current version is 3.6.1, released on 2025-12-15, with a release cadence of approximately every 6 months.

pip install networkx
INSTALL
IMPORT
SIG · NETWORKX
N
networkx
datapythonv3.6.1
Install
2.7s avg
Import
413ms
Disk
32MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v3.4.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.103.95 runs
installs and imports cleanly · install 0.0s · import 0.436s · 32MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 2.7s · import 0.390s · 32MB
32MB installed
● package 32MB
Code
Verified usage

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

Graph
from networkx import Graph
Direct import of Graph class from networkx module.
add_path
G.add_path([0, 1, 2, 3])
Use the method directly on a Graph instance.

A simple example to create a graph, add nodes and edges, and visualize it using matplotlib.

import networkx as nx # Create an empty graph G = nx.Graph() # Add nodes and edges G.add_nodes_from([1, 2, 3]) G.add_edges_from([(1, 2), (2, 3)]) # Draw the graph import matplotlib.pyplot as plt nx.draw(G, with_labels=True) plt.show()
Debug
Known issues
breakingThe 'release' module has been removed in NetworkX 3.0. Direct import of 'release' will result in an ImportError.
fix
Remove the import statement 'from networkx import release' from your code.
affects: >=3.0
deprecatedThe 'add_path' function is now a method of the Graph class and should be called on a Graph instance.
fix
Replace 'networkx.add_path(G, [0, 1, 2, 3])' with 'G.add_path([0, 1, 2, 3])'.
affects: >=3.0
gotchaEnsure that all optional dependencies (numpy, scipy, matplotlib, pandas) are installed for full functionality, especially for graph visualization and advanced computations.
fix
Install optional dependencies using 'pip install networkx[default]'.
affects: >=3.0
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'networkx'
The NetworkX library is not installed in the current Python environment or the environment is not correctly activated.
fix
Run `pip install networkx` in your terminal or command prompt. If using Anaconda, use `conda install networkx` instead.
AttributeError: module 'networkx' has no attribute 'info'
The `info()` method was removed in NetworkX 3.0.0; direct attribute access or other specific functions should be used instead for graph summaries.
fix
Access graph properties directly (e.g., `G.number_of_nodes()`, `G.number_of_edges()`) or print the graph object `print(G)` for a basic summary. If a detailed summary is needed for compatibility with older code, consider `nx.graph_info(G)` if available, or update the code to use newer API features.
AttributeError: module 'networkx' has no attribute 'from_pandas_edgelist'
The `from_pandas_edgelist` function was introduced in NetworkX version 2.0.0. This error occurs when using an older version of the library.
fix
Upgrade NetworkX to version 2.0 or newer by running `pip install --upgrade networkx` in your terminal or command prompt.
networkx.exception.NetworkXError: Edge tuple ('A',) must be a 2-tuple or 3-tuple.
This error occurs when the `add_edges_from()` method receives an iterable where individual elements are not valid 2-tuples (source, target) or 3-tuples (source, target, data_dict) representing edges.
fix
Ensure the input to `add_edges_from` is a list or iterable of tuples, where each tuple strictly contains two (source, target) or three elements (source, target, edge_attributes), e.g., `G.add_edges_from([(1, 2), (2, 3, {'weight': 0.5})])`.
SyntaxError: invalid syntax (when running `pip install networkx`)
The `pip install` command is being executed within the Python interpreter's interactive shell, not directly in the system's command prompt or terminal.
fix
Exit the Python interpreter (by typing `exit()` and pressing Enter) and then run `pip install networkx` directly in your operating system's command prompt (Windows) or terminal (macOS/Linux).
Upgrade
Version history
3.6.1latest on PyPI · released Dec 8, 2025
Audit
Dependencies
numpyoptionalfor numerical computations
scipyoptionalfor scientific computations
matplotliboptionalfor graph visualization
pandasoptionalfor data manipulation
Agent activity
11 hits · last 30 days
node
10
Resources
networkx — pip install networkx · libregistry