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

File metadata

  • Download URL: swarmauri_tool_jupyterexportpython-0.9.3.dev17.tar.gz
  • Upload date:
  • Size: 7.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","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.dev17.tar.gz
Algorithm Hash digest
SHA256 97e9244f1588bdfdd8d3bf82a169939dbb013b99a74d9a3e67a61f721a910e7b
MD5 a5c281a03eefa1e328dc3745ad8e3633
BLAKE2b-256 ae2c52fb5851a838ad539722a03ee5ba9fcd1ea57494eda45594bd35b3ba82e5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: swarmauri_tool_jupyterexportpython-0.9.3.dev17-py3-none-any.whl
  • Upload date:
  • Size: 9.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","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.dev17-py3-none-any.whl
Algorithm Hash digest
SHA256 632afa4802bceb115c4c4d2fd9835540c814aaa5de1ef130a2f9f8f70ec2e30d
MD5 2492f405c310b4e06da2934160c917ee
BLAKE2b-256 a20b6271d839271e5fdeddf168f0c724eb43308fb41cae2f1ddc5809a10e6190

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