Skip to main content

A tool that exports a Jupyter Notebook to a Python script using nbconvert’s PythonExporter, facilitating code extraction.

Project description

Swarmauri Logo

PyPI - Downloads Hits PyPI - Python Version PyPI - License PyPI - swarmauri_tool_jupyterexportpython


Swarmauri Tool Jupyter Export Python

Exports a Jupyter NotebookNode to a Python script using nbconvert’s PythonExporter with optional custom templates.

Features

  • Accepts a notebook object (nbformat.NotebookNode) and returns the rendered .py source.
  • Supports passing an nbconvert template for custom formatting.
  • Returns {"exported_script": ...} on success or {"error": ...} on failure.

Prerequisites

  • Python 3.10 or newer.
  • nbconvert/nbformat installed (pulled automatically).

Installation

# pip
pip install swarmauri_tool_jupyterexportpython

# poetry
poetry add swarmauri_tool_jupyterexportpython

# uv (pyproject-based projects)
uv add swarmauri_tool_jupyterexportpython

Quickstart

import nbformat
from swarmauri_tool_jupyterexportpython import JupyterExportPythonTool

notebook = nbformat.read("notebooks/example.ipynb", as_version=4)
exporter = JupyterExportPythonTool()
result = exporter(notebook, template_file=None)

if "exported_script" in result:
    Path("notebooks/example.py").write_text(result["exported_script"], encoding="utf-8")
else:
    print("Error:", result["error"])

Tips

  • Use custom templates to control cell separators or code comments—pass a .tpl file via template_file.
  • Pair with notebook execution tools (execute → export to .py) to operationalize notebooks as Python scripts.

Want to help?

If you want to contribute to swarmauri-sdk, read up on our guidelines for contributing that will help you get started.

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

Built Distribution

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

File details

Details for the file swarmauri_tool_jupyterexportpython-0.9.3.dev9.tar.gz.

File metadata

  • Download URL: swarmauri_tool_jupyterexportpython-0.9.3.dev9.tar.gz
  • Upload date:
  • Size: 7.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for swarmauri_tool_jupyterexportpython-0.9.3.dev9.tar.gz
Algorithm Hash digest
SHA256 4ef71291ec56ff85acab182a9e6d030be1119b17f88c8925d7dae738391263a5
MD5 678660aac476a2508f2dfbfb1c362ae7
BLAKE2b-256 a76aafb9496c294ae1564d59e6dda0271efc3d88c69f16c8ad9da50b37bb3f5d

See more details on using hashes here.

File details

Details for the file swarmauri_tool_jupyterexportpython-0.9.3.dev9-py3-none-any.whl.

File metadata

  • Download URL: swarmauri_tool_jupyterexportpython-0.9.3.dev9-py3-none-any.whl
  • Upload date:
  • Size: 9.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for swarmauri_tool_jupyterexportpython-0.9.3.dev9-py3-none-any.whl
Algorithm Hash digest
SHA256 6db5da45f65ce8be0127d045a5b052c17422c9fd3b4c2e3ff5063c5e78131ee0
MD5 3d68a6ec08b179c76720a3c8a2f650b3
BLAKE2b-256 b4df1422bcb51a995cc32f6c44dc5b23657d33d4a0662b21d024e3352bc57811

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