Guide/In production
Troubleshooting
1 min readFrom the README
On this page 8
Top issues and their fixes.
ImportError: cannot import name '_fnx' from 'franken_networkx'
The cdylib didn't build or didn't get installed. Cause and fix:
- You installed from source but the build silently failed. Re-run
maturin develop --release --features pyo3/abi3-py310and read the full output. - A stale wheel from a previous build is shadowing the new one.
pip uninstall franken-networkx && pip install franken-networkx. - You're on Python < 3.10. ABI3-py310 means 3.10 is the floor; upgrade Python.
Backend isn't dispatching: nx.shortest_path still slow
import networkx as nx
nx.config.backend_priority = ["franken_networkx"]
# Now call nx.shortest_path(G, ...)
If still slow, check:
import franken_networkx
print(franken_networkx.__version__) # PyPI's current release is 0.4.1
import networkx as nx
print(nx.config.backend_priority) # should contain "franken_networkx"
# Did NetworkX actually pick up the entry point?
import importlib.metadata as im
print([e.name for e in im.entry_points(group="networkx.backends")])
# → should include "franken_networkx"
If the entry point isn't visible, your install is broken. Reinstall.
NotImplementedError: BackendInterface has no attribute '<name>'
The algorithm isn't in _SUPPORTED_ALGORITHMS and you passed backend="franken_networkx" explicitly (the per-call form raises rather than falling back). Fix: drop the explicit kwarg and rely on backend_priority-based fallback, or call fnx.<name> directly.
A result that doesn't match NetworkX
Reproduce both sides:
import networkx as nx, franken_networkx as fnx
G_nx = nx.path_graph(10)
G_fnx = fnx.path_graph(10)
print(nx.shortest_path(G_nx, 0, 9))
print(fnx.shortest_path(G_fnx, 0, 9))
If they differ and the difference isn't in docs/upstream_divergence_ledger.md, it's a bug. Please open an issue with franken_networkx.__version__ and networkx.__version__.
RuntimeError: dictionary changed size during iteration
You mutated a graph while iterating it. fnx matches NetworkX's behavior exactly here: iteration views are live, and mutating during iteration raises. Use list(G.nodes()) to snapshot.
"Stale wheel" detected during pytest
The conformance test layer detects a previously-installed fnx wheel with a mismatched API surface and skips backend-dispatch tests rather than report spurious failures (br-r37-c1-... cycle, see tests/python/test_backend_dispatch_recursion_parity.py). Fix: rebuild with maturin develop --release.
Performance is worse than NetworkX for tiny graphs (< 50 nodes)
Expected. The dispatch + PyO3 marshaling cost dominates for graphs that small. Use NetworkX directly, or just accept the constant overhead. fnx wins at scale, not on micro-benchmarks.
Multiprocessing crashes with _fnx segfaults
PyO3 extension modules need to be re-imported in each spawned process. Use multiprocessing.set_start_method("spawn") (not fork) on macOS and most modern Linux setups.