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➜.pywith 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]
- GUI:
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")
- CLI:
- 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|minimalchoose a theme--no-metadatadisable metadata preservation--no-round-tripdisable round‑trip metadata--no-semantic-markdowndisable semantic Markdown--quality-analysisenable code quality checks--max-line-length 88wrap text/comments at length--statsshow 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.tomlviareadme = "README.md"anddescription. - To update what appears on PyPI:
- Edit this README.
- Bump the version in
pyproject.tomland innotebook_converter/src/notebook_converter/__init__.py. - 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.
Metadata
Release files for notebook-to-code 3.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| notebook_to_code-3.0.4.tar.gz | 29.0 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| notebook_to_code-3.0.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 62.2 kB
Release files / notebook_to_code-3.0.4.tar.gz
| Download URL | notebook_to_code-3.0.4.tar.gz |
|---|---|
| Size | 29.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4825190d8feca695e8fd0425ab1b656d9a05838456b08b31d449bb1b930f696f
|
|
BLAKE2b-256 checksum How to use checksums |
de329761a9298b790235be5eab4ead30d9b39e34cc3324255969e4eb2af6e41c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.0
|
Release files / notebook_to_code-3.0.4-py3-none-any.whl
| Download URL | notebook_to_code-3.0.4-py3-none-any.whl |
|---|---|
| Size | 33.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
594604b52a3355b5d6e3073f723134b52e1eaba3e065a2cb1408a7c4cdb13130
|
|
BLAKE2b-256 checksum How to use checksums |
90a4dfa33963f29156423bacc30f9e22bf5c1525da08b50d8ba333b6e53f9f61
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.0
|
Security for notebook-to-code 3.0.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.