Install & Compatibility
Where this runs
tested against v0.17.1 · 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
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.062s · 96.3MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 4.1s · import 0.056s · 92MB
96MB installed
● package 96MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
PyGraph
✓ import retworkx as rx; g = rx.PyGraph()
✗ from retworkx import PyGraph
Direct import is fine, but idiomatic usage is `import retworkx as rx`
PyDiGraph
✓ import retworkx as rx; g = rx.PyDiGraph()
✗ from retworkx import PyDiGraph as DiGraph
Avoid aliasing to avoid confusion with other graph libraries
Create a directed acyclic graph, add nodes and edges, and print them.
import retworkx as rx
dag = rx.PyDiGraph()
node_a = dag.add_node('A')
node_b = dag.add_child(node_a, 'B', None)
print(dag.nodes())
print(dag.edges())
Debug
Known issues
breakingVersion 0.14.0 replaced the original function-based API with the class-based API (PyGraph, PyDiGraph). Code using `from retworkx import *` or older function names will break.fixMigrate to using PyGraph and PyDiGraph classes. See migration guide at https://qiskit.org/documentation/retworkx/
affects: <0.14.0
deprecatedThe `digraph` and `graph` constructor functions are deprecated and removed in 0.14.0.fixReplace `retworkx.digraph()` with `retworkx.PyDiGraph()` and similarly for undirected graphs.
affects: >=0.10.0, <0.14.0
gotchaNode indices are integers returned by add_node/add_child; do not rely on them being sequential or stable after deletions.fixAssign custom node data or use node indices immediately; do not assume order.
affects: all
gotchaEdge weights are optional but must be passed as the third argument to add_child; passing None is acceptable but can lead to type confusion.fixAlways provide an explicit weight (or None) to avoid unexpected behavior.
affects: all
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'retworkx'
retworkx not installed or environment not activated
fixRun `pip install retworkx` in the correct environment (Python >=3.9).
TypeError: add_child() missing 1 required positional argument: 'obj'
Missing the edge weight argument in add_child
fixProvide a third argument, e.g., `dag.add_child(parent, child, None)`.
AttributeError: module 'retworkx' has no attribute 'digraph'
Using the deprecated function name from old versions (<0.14.0)
fixUse `retworkx.PyDiGraph()` instead of `retworkx.digraph()`.
Upgrade
Version history
0.17.1latest on PyPI · released Sep 15, 2025
Audit
Dependencies
No dependency data recorded yet.