Skip to main content

A tool to run Jupyter notebooks as Python scripts

Project description

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.

Installation

  • Requirements: Python >= 3.7

Install directly from Git using pip:

# HTTPS
pip install "git+https://github.com/dschaub95/run-ipynb"

After installation, a CLI named run-ipynb will be available.

Usage

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

Examples

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

# Keep the .py file for inspection and overwrite if it already exists
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

Notes

  • jupyter is installed as a dependency and must be available on your PATH for nbconvert to work.

Project details


Download files

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

Source Distribution

run_ipynb-0.1.0.tar.gz (179.9 kB view details)

Uploaded Source

Built Distribution

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

run_ipynb-0.1.0-py3-none-any.whl (3.2 kB view details)

Uploaded Python 3

File details

Details for the file run_ipynb-0.1.0.tar.gz.

File metadata

  • Download URL: run_ipynb-0.1.0.tar.gz
  • Upload date:
  • Size: 179.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for run_ipynb-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a9862545ae0cb32294feec772127aa30c1d12832f0ff6ad4c34a9c6fefaa826f
MD5 8218ae80e7451735f934ed6c3a89e5a7
BLAKE2b-256 45248dcfb3e1a0f09d65b0d9f07178c4d0db3d781c6bc4d1f653d8558f444825

See more details on using hashes here.

Provenance

The following attestation bundles were made for run_ipynb-0.1.0.tar.gz:

Publisher: release.yaml on dschaub95/run-ipynb

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file run_ipynb-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: run_ipynb-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for run_ipynb-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 644afee838c2fb0c7553201815aa9d3c88f32a50aa20de359c05ef446d5d99aa
MD5 9fbd1af5740045691824119a67d50698
BLAKE2b-256 cb7e4a3716b684ae0adb3b75de2c9cfb40eaaf9d74fe8db0111b33085602fd82

See more details on using hashes here.

Provenance

The following attestation bundles were made for run_ipynb-0.1.0-py3-none-any.whl:

Publisher: release.yaml on dschaub95/run-ipynb

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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