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.0.dev22.tar.gz.

File metadata

  • Download URL: swarmauri_tool_jupyterexportpython-0.9.0.dev22.tar.gz
  • Upload date:
  • Size: 7.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.27 {"installer":{"name":"uv","version":"0.9.27","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.0.dev22.tar.gz
Algorithm Hash digest
SHA256 55fbc381ec6a24287a04243c5a44f93a6542ae9a612b66260dafb09383804467
MD5 736d9085422fe46b57927588ef3f1371
BLAKE2b-256 fae5ea6b9aba7adb969cfbb090154060260a909dff9c3691d5e00979a69b259d

See more details on using hashes here.

File details

Details for the file swarmauri_tool_jupyterexportpython-0.9.0.dev22-py3-none-any.whl.

File metadata

  • Download URL: swarmauri_tool_jupyterexportpython-0.9.0.dev22-py3-none-any.whl
  • Upload date:
  • Size: 9.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.27 {"installer":{"name":"uv","version":"0.9.27","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.0.dev22-py3-none-any.whl
Algorithm Hash digest
SHA256 b71c336297af1aa557fb5684684080cab2ab184f91aa24261e60969e3d629475
MD5 645395c3ceaf3bbcddcb1744d3ad836c
BLAKE2b-256 39f68963de830717127eb061de2d8dd2f7d2ccba1cfc11e5b5af4d00882fa2de

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