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.dev13.tar.gz.

File metadata

  • Download URL: swarmauri_tool_jupyterexportpython-0.9.3.dev13.tar.gz
  • Upload date:
  • Size: 7.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.8 {"installer":{"name":"uv","version":"0.10.8","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.dev13.tar.gz
Algorithm Hash digest
SHA256 a5c44974367fa0d059f57e2c0aeb9bb2e563557355f7e605243e28585f953e44
MD5 4ff7c2e6ed8c341a5635a139a5f4228a
BLAKE2b-256 b4c61690149e049475676f2758571b76d5fd71c595cdb7ca228e489aecde215a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: swarmauri_tool_jupyterexportpython-0.9.3.dev13-py3-none-any.whl
  • Upload date:
  • Size: 9.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.8 {"installer":{"name":"uv","version":"0.10.8","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.dev13-py3-none-any.whl
Algorithm Hash digest
SHA256 830dbf982f402d9277dfef7d2976411704e48cfc6550ce2f774711be615197d3
MD5 2788bbd838324a582a698f843b04cb49
BLAKE2b-256 0b00b8c3f2ae52001525e7b0862aaf895e7c81e94a68b8b9d4331ba202e04a59

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