Skip to main content

run-ipynb

Run Jupyter notebooks as plain Python scripts from the command line.

This tool converts a .ipynb to .py, removes IPython-only lines, ensures a non-interactive Matplotlib backend, optionally adjusts sys.path when os.chdir(...) is used, executes the script, and cleans up the generated file by default.

Usage

You can directly use the tool with uv:

uvx run-ipynb path/to/notebook.ipynb [--keep] [--yes]

Optionally specify a Python interpreter:

uvx run-ipynb path/to/notebook.ipynb --python /path/to/python

You can also rely on your current shell's interpreter by setting RUN_IPYNB_PYTHON:

export RUN_IPYNB_PYTHON=$(which python)
uvx run-ipynb path/to/notebook.ipynb

Otherwise run:

pip install run-ipynb

and then:

run-ipynb path/to/notebook.ipynb [--keep] [--yes]
  • notebook_path: Path to the .ipynb notebook to run
  • -k, --keep: Keep the generated .py file after execution
  • -y, --yes: Automatically overwrite an existing .py file without prompting
  • -p, --python: Python interpreter to execute the generated script (defaults to the current interpreter)

If --python is not provided, run-ipynb checks in order:

  • RUN_IPYNB_PYTHON
  • RUN_IPYNB_ENV_PYTHON
  • active virtual environments (VIRTUAL_ENV, CONDA_PREFIX, MAMBA_PREFIX, Pipenv, Poetry, etc.)
  • which python
  • the interpreter running the CLI

Examples

# Basic: convert, run, and remove the temporary .py file
uvx run-ipynb notebooks/analysis.ipynb

# Keep the .py file for inspection and overwrite if it already exists
uvx run-ipynb notebooks/analysis.ipynb --keep --yes

What it does

  • Converts the notebook with jupyter nbconvert --to script
  • Removes get_ipython().run_line_magic lines
  • Sets Matplotlib backend to Agg for headless environments
  • If os.chdir(...) is detected, appends os.getcwd() to sys.path right after the change
  • Executes the resulting script with your current Python interpreter
  • Deletes the generated .py file unless --keep is passed

Metadata

Release files for run-ipynb 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for run-ipynb 0.1.2
File Size Uploaded
run_ipynb-0.1.2.tar.gz 182.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for run-ipynb 0.1.2
File Interpreter ABI Platform
run_ipynb-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 186.5 kB

Release files / run_ipynb-0.1.2.tar.gz

Download URL run_ipynb-0.1.2.tar.gz
Size 182.4 kB
Tags Source
SHA-256 checksum
How to use checksums
b10bd2f976769a761e589e49fb5d0719c8c7623c54b7599e34f874c8c1653ac3
BLAKE2b-256 checksum
How to use checksums
c1b18a386411898b15dacb2c7c380d8e0a87ada01fc6e47b5ead3f56df487c16
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 12, 2026.

Transparency log

Release files / run_ipynb-0.1.2-py3-none-any.whl

Download URL run_ipynb-0.1.2-py3-none-any.whl
Size 4.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2aa9ae8c1adebdd4327a66824d149c8f60bff34cc5840cbddb23552ba9b4df0d
BLAKE2b-256 checksum
How to use checksums
a5667598fe0ca6fa78146c19bed654b7decfa7ac3e8339f1497b249cef028719
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 12, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page