Skip to main content

Advanced Jupyter Notebook to Python script converter with round-trip support

Project description

notebook-to-code

Jupyter Notebook ➜ Python converter with round‑trip metadata, semantic Markdown processing, a pluginable theme system, batch mode, and a friendly CLI.

Key features

  • Convert .ipynb.py with clear, annotated cells
  • Optional reverse conversion (annotated .py.ipynb)
  • Semantic Markdown processing and wrapping
  • Round‑trip metadata to validate integrity
  • Batch processing for folders/patterns
  • Theme plugins (e.g., default, minimal)
  • Rich CLI output (optional)

Install

  • Stable release:
    • pip install notebook-to-code
  • Extras:
    • GUI: pip install notebook-to-code[gui]
    • Analysis: pip install notebook-to-code[analysis]
    • Dev: pip install notebook-to-code[dev]

Quickstart

  • Convert a single notebook:
    • CLI: notebook-to-code convert path/to/notebook.ipynb -o out.py --stats
    • Python one‑liner:
      • from notebook_converter import convert_notebook; convert_notebook("path/to/notebook.ipynb", "out.py")
  • Batch convert a folder:
    • notebook-to-code batch notebooks/ -o converted/ --pattern *.ipynb
  • Reverse (annotated .py ➜ .ipynb):
    • notebook-to-code reverse script.py -o out.ipynb
  • List themes:
    • notebook-to-code themes

CLI Options (highlights)

  • --theme default|minimal choose a theme
  • --no-metadata disable metadata preservation
  • --no-round-trip disable round‑trip metadata
  • --no-semantic-markdown disable semantic Markdown
  • --quality-analysis enable code quality checks
  • --max-line-length 88 wrap text/comments at length
  • --stats show conversion statistics

Python API (minimal)

from notebook_converter import AdvancedNotebookConverter, ConversionOptions

options = ConversionOptions(semantic_markdown=True, round_trip_metadata=True)
converter = AdvancedNotebookConverter(options=options)

out_file, stats = converter.convert_notebook("path/to/notebook.ipynb", "out.py")
print("Converted:", out_file)

Project structure

  • Package: notebook_converter (import path)
  • CLI: notebook-to-code (entry point)
  • Source: notebook_converter/src/notebook_converter/

Contributing

  • Create a virtual env and install in editable mode:
    • pip install -e .[dev]
  • Run tests (if configured):
    • pytest -q

License

  • MIT

How PyPI description works

  • The "Project description" on PyPI is rendered from this README.md.
  • Configuration is set in pyproject.toml via readme = "README.md" and description.
  • To update what appears on PyPI:
    1. Edit this README.
    2. Bump the version in pyproject.toml and in notebook_converter/src/notebook_converter/__init__.py.
    3. Rebuild and upload a new release:
      • py -m build && py -m twine upload dist/*
  • PyPI does not allow editing a release’s metadata in place; publish a new version to change the description.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

notebook_to_code-3.0.4.tar.gz (29.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

notebook_to_code-3.0.4-py3-none-any.whl (33.2 kB view details)

Uploaded Python 3

File details

Details for the file notebook_to_code-3.0.4.tar.gz.

File metadata

  • Download URL: notebook_to_code-3.0.4.tar.gz
  • Upload date:
  • Size: 29.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.0

File hashes

Hashes for notebook_to_code-3.0.4.tar.gz
Algorithm Hash digest
SHA256 4825190d8feca695e8fd0425ab1b656d9a05838456b08b31d449bb1b930f696f
MD5 d699c10ca356fabb917157e012eb0bec
BLAKE2b-256 de329761a9298b790235be5eab4ead30d9b39e34cc3324255969e4eb2af6e41c

See more details on using hashes here.

File details

Details for the file notebook_to_code-3.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for notebook_to_code-3.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 594604b52a3355b5d6e3073f723134b52e1eaba3e065a2cb1408a7c4cdb13130
MD5 1912d9ca19ceab6100441527cf4cb42d
BLAKE2b-256 90a4dfa33963f29156423bacc30f9e22bf5c1525da08b50d8ba333b6e53f9f61

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page