{"library":"nbdime","title":"nbdime (Jupyter Notebook Diff & Merge)","description":"nbdime provides tools for diffing and merging Jupyter Notebooks. It offers both a command-line interface for integration with version control systems (like Git) and a visual, interactive web interface for richer diffs and merges. The library is currently at version 4.0.4 and is actively maintained by the Project Jupyter team, with releases often coinciding with major JupyterLab updates.","language":"python","status":"active","last_verified":"Sun May 17","install":{"commands":["pip install nbdime"],"cli":{"name":"nbdime","version":"4.0.4"}},"imports":["from nbdime.diff_files import diff_notebooks","from nbdime.merge_files import merge_notebooks","from nbdime.webapp import main"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import nbformat\nfrom pathlib import Path\nimport subprocess\n\n# Create two dummy notebooks for demonstration\nnb1 = nbformat.v4.new_notebook()\nnb1.cells.append(nbformat.v4.new_code_cell(\"print('Hello from A')\"))\nnb1_path = Path(\"notebook_a.ipynb\")\nwith open(nb1_path, \"w\", encoding=\"utf-8\") as f:\n    nbformat.write(nb1, f)\n\nnb2 = nbformat.v4.new_notebook()\nnb2.cells.append(nbformat.v4.new_code_cell(\"print('Hello from B')\"))\nnb2.cells.append(nbformat.v4.new_markdown_cell(\"## A new section\\nThis is a new section in notebook B.\"))\nnb2_path = Path(\"notebook_b.ipynb\")\nwith open(nb2_path, \"w\", encoding=\"utf-8\") as f:\n    nbformat.write(nb2, f)\n\nprint(f\"Created {nb1_path} and {nb2_path}\")\n\n# Run nbdime diff from the command line\nprint(\"\\n--- Running nbdime diff in terminal mode ---\")\ntry:\n    # Use --diff-alg=terminal to get output directly in the console\n    result = subprocess.run(\n        [\"nbdime\", \"diff\", str(nb1_path), str(nb2_path), \"--diff-alg=terminal\"],\n        capture_output=True, text=True, check=True\n    )\n    print(result.stdout)\nexcept subprocess.CalledProcessError as e:\n    print(f\"Error running nbdime diff: {e.stderr}\")\n\n# To open in a browser (default behavior if --diff-alg is not specified)\n# print(\"\\n--- Running nbdime diff in browser (opens new tab) ---\")\n# subprocess.Popen([\"nbdime\", \"diff\", str(nb1_path), str(nb2_path)])\n# print(\"Check your browser for the visual diff. Press Ctrl+C to stop this script after viewing.\")\n# import time; time.sleep(10) # Give time to view, then uncomment cleanup\n\n# Clean up\nnb1_path.unlink()\nnb2_path.unlink()\nprint(f\"\\nCleaned up {nb1_path} and {nb2_path}\")","lang":"python","description":"This quickstart demonstrates how to create two simple Jupyter notebooks and then use the `nbdime` command-line tool to perform a diff between them, showing the output directly in the terminal. The default `nbdime diff` command would open a browser for a richer visual diff.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-17","installed_version":"4.0.4","pypi_latest":"4.0.4","is_stale":false,"summary":{"python_range":"3.10–3.9","success_rate":100,"avg_install_s":9.4,"avg_import_s":null,"wheel_type":"wheel"},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"nbdime","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"92.8M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"nbdime","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":9.6,"import_time_s":null,"mem_mb":null,"disk_size":"90M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"nbdime","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"101.5M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"nbdime","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":9.9,"import_time_s":null,"mem_mb":null,"disk_size":"99M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"nbdime","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"91.6M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"nbdime","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":8,"import_time_s":null,"mem_mb":null,"disk_size":"89M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"nbdime","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"91.5M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"nbdime","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":8,"import_time_s":null,"mem_mb":null,"disk_size":"89M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"nbdime","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"92.9M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"nbdime","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":11.3,"import_time_s":null,"mem_mb":null,"disk_size":"90M"}]}}