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
.ipynbnotebook to run - -k, --keep: Keep the generated
.pyfile after execution - -y, --yes: Automatically overwrite an existing
.pyfile 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_magiclines - Sets Matplotlib backend to
Aggfor headless environments - If
os.chdir(...)is detected, appendsos.getcwd()tosys.pathright after the change - Executes the resulting script with your current Python interpreter
- Deletes the generated
.pyfile unless--keepis passed
Notes
jupyteris installed as a dependency and must be available on yourPATHfornbconvertto work.
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a9862545ae0cb32294feec772127aa30c1d12832f0ff6ad4c34a9c6fefaa826f
|
|
| MD5 |
8218ae80e7451735f934ed6c3a89e5a7
|
|
| BLAKE2b-256 |
45248dcfb3e1a0f09d65b0d9f07178c4d0db3d781c6bc4d1f653d8558f444825
|
Provenance
The following attestation bundles were made for run_ipynb-0.1.0.tar.gz:
Publisher:
release.yaml on dschaub95/run-ipynb
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
run_ipynb-0.1.0.tar.gz -
Subject digest:
a9862545ae0cb32294feec772127aa30c1d12832f0ff6ad4c34a9c6fefaa826f - Sigstore transparency entry: 590197742
- Sigstore integration time:
-
Permalink:
dschaub95/run-ipynb@17fbfb8b16577f6c5abf45673ac4efac619a9358 -
Branch / Tag:
refs/tags/v0.0.1 - Owner: https://github.com/dschaub95
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@17fbfb8b16577f6c5abf45673ac4efac619a9358 -
Trigger Event:
release
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
644afee838c2fb0c7553201815aa9d3c88f32a50aa20de359c05ef446d5d99aa
|
|
| MD5 |
9fbd1af5740045691824119a67d50698
|
|
| BLAKE2b-256 |
cb7e4a3716b684ae0adb3b75de2c9cfb40eaaf9d74fe8db0111b33085602fd82
|
Provenance
The following attestation bundles were made for run_ipynb-0.1.0-py3-none-any.whl:
Publisher:
release.yaml on dschaub95/run-ipynb
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
run_ipynb-0.1.0-py3-none-any.whl -
Subject digest:
644afee838c2fb0c7553201815aa9d3c88f32a50aa20de359c05ef446d5d99aa - Sigstore transparency entry: 590197897
- Sigstore integration time:
-
Permalink:
dschaub95/run-ipynb@17fbfb8b16577f6c5abf45673ac4efac619a9358 -
Branch / Tag:
refs/tags/v0.0.1 - Owner: https://github.com/dschaub95
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@17fbfb8b16577f6c5abf45673ac4efac619a9358 -
Trigger Event:
release
-
Statement type: