{"id":361,"library":"networkx","title":"NetworkX","description":"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.","status":"active","version":"3.6.1","language":"python","source_language":"en","source_url":"https://github.com/networkx/networkx","tags":["graph","network","visualization","algorithms"],"install":[{"cmd":"pip install networkx","lang":"bash","label":"Install NetworkX"}],"dependencies":[{"reason":"for numerical computations","package":"numpy","optional":true},{"reason":"for scientific computations","package":"scipy","optional":true},{"reason":"for graph visualization","package":"matplotlib","optional":true},{"reason":"for data manipulation","package":"pandas","optional":true}],"imports":[{"note":"Direct import of Graph class from networkx module.","symbol":"Graph","correct":"from networkx import Graph"},{"note":"Use the method directly on a Graph instance.","symbol":"add_path","correct":"G.add_path([0, 1, 2, 3])"}],"quickstart":{"code":"import networkx as nx\n\n# Create an empty graph\nG = nx.Graph()\n\n# Add nodes and edges\nG.add_nodes_from([1, 2, 3])\nG.add_edges_from([(1, 2), (2, 3)])\n\n# Draw the graph\nimport matplotlib.pyplot as plt\nnx.draw(G, with_labels=True)\nplt.show()","lang":"python","description":"A simple example to create a graph, add nodes and edges, and visualize it using matplotlib."},"warnings":[{"fix":"Remove the import statement 'from networkx import release' from your code.","message":"The 'release' module has been removed in NetworkX 3.0. Direct import of 'release' will result in an ImportError.","severity":"breaking","affected_versions":">=3.0"},{"fix":"Replace 'networkx.add_path(G, [0, 1, 2, 3])' with 'G.add_path([0, 1, 2, 3])'.","message":"The 'add_path' function is now a method of the Graph class and should be called on a Graph instance.","severity":"deprecated","affected_versions":">=3.0"},{"fix":"Install optional dependencies using 'pip install networkx[default]'.","message":"Ensure that all optional dependencies (numpy, scipy, matplotlib, pandas) are installed for full functionality, especially for graph visualization and advanced computations.","severity":"gotcha","affected_versions":">=3.0"}],"env_vars":null,"last_verified":"2026-05-12T13:17:26.267Z","next_check":"2026-06-26T00:00:00.000Z","problems":[{"fix":"Run `pip install networkx` in your terminal or command prompt. If using Anaconda, use `conda install networkx` instead.","cause":"The NetworkX library is not installed in the current Python environment or the environment is not correctly activated.","error":"ModuleNotFoundError: No module named 'networkx'"},{"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.","cause":"The `info()` method was removed in NetworkX 3.0.0; direct attribute access or other specific functions should be used instead for graph summaries.","error":"AttributeError: module 'networkx' has no attribute 'info'"},{"fix":"Upgrade NetworkX to version 2.0 or newer by running `pip install --upgrade networkx` in your terminal or command prompt.","cause":"The `from_pandas_edgelist` function was introduced in NetworkX version 2.0.0. This error occurs when using an older version of the library.","error":"AttributeError: module 'networkx' has no attribute 'from_pandas_edgelist'"},{"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})])`.","cause":"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.","error":"networkx.exception.NetworkXError: Edge tuple ('A',) must be a 2-tuple or 3-tuple."},{"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).","cause":"The `pip install` command is being executed within the Python interpreter's interactive shell, not directly in the system's command prompt or terminal.","error":"SyntaxError: invalid syntax (when running `pip install networkx`)"}],"ecosystem":"pypi","meta_description":null,"install_score":100,"install_tag":"verified","quickstart_score":0,"quickstart_tag":"stale","pypi_latest":null,"install_checks":{"last_tested":"2026-05-12","tag":"verified","tag_description":"installs cleanly on critical runtimes, fast import, recently tested","results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.42,"mem_mb":15.4,"disk_size":"32.0M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.33,"mem_mb":15.4,"disk_size":"32M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.56,"mem_mb":16.9,"disk_size":"38.2M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.45,"mem_mb":16.9,"disk_size":"39M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.48,"mem_mb":16,"disk_size":"29.2M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.48,"mem_mb":16,"disk_size":"30M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.42,"mem_mb":14.9,"disk_size":"28.7M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.42,"mem_mb":14.9,"disk_size":"29M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.33,"mem_mb":12.3,"disk_size":"30.9M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.27,"mem_mb":12.3,"disk_size":"31M"}]},"quickstart_checks":{"last_tested":"2026-04-23","tag":"stale","tag_description":"widespread failures or data too old to trust","results":[{"runtime":"python:3.10-alpine","exit_code":1},{"runtime":"python:3.10-slim","exit_code":1},{"runtime":"python:3.11-alpine","exit_code":1},{"runtime":"python:3.11-slim","exit_code":1},{"runtime":"python:3.12-alpine","exit_code":1},{"runtime":"python:3.12-slim","exit_code":1},{"runtime":"python:3.13-alpine","exit_code":1},{"runtime":"python:3.13-slim","exit_code":1},{"runtime":"python:3.9-alpine","exit_code":1},{"runtime":"python:3.9-slim","exit_code":1}]}}