Registry / data / papermill

papermill

JSON →
library2.7.0pypypi✓ verified 24d ago

Papermill is a Python library that allows you to parameterize and execute Jupyter and nteract Notebooks. It's widely used for creating dynamic reports, running ETL jobs, and orchestrating data science workflows where notebook execution is a core component. The current version is 2.7.0, and it generally follows a release cadence tied to new features or critical bug fixes.

pip install papermill
INSTALL
IMPORT
SIG · PAPERMILL
P
papermill
datapythonv2.7.0
Install
5.7s avg
Import
1217ms
Disk
44MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.7.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 1.262s · 44.7MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 5.7s · import 1.172s · 42MB
44MB installed
● package 44MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

execute_notebook
from papermill import execute_notebook
import papermill as pm

This quickstart demonstrates how to use `papermill.execute_notebook` to run a Jupyter notebook with injected parameters. It creates a simple input notebook on the fly, executes it, and saves the output. The `parameters` dictionary is used to override variables defined in cells tagged with 'parameters' in the input notebook. Error handling is included for robust execution.

import papermill as pm import os # Create a dummy input notebook file for demonstration notebook_content = ''' { "cells": [ { "cell_type": "code", "execution_count": null, "metadata": {"tags": ["parameters"]}, "outputs": [], "source": ["# Parameters injected here"] \ + ["message = 'default'"], "user_expression": [] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": ["print(f'Hello from Papermill: {message}')"], "user_expression": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.7" # Placeholder, will use current env's python } }, "nbformat": 4, "nbformat_minor": 5 } ''' with open('input_notebook.ipynb', 'w') as f: f.write(notebook_content.replace('3.9.7', f'{os.sys.version_info.major}.{os.sys.version_info.minor}.{os.sys.version_info.micro}')) input_path = 'input_notebook.ipynb' output_path = 'output_notebook.ipynb' parameters = {'message': 'Papermill is awesome!'} try: # Execute the notebook with parameters pm.execute_notebook( input_path, output_path, parameters=parameters, report_mode=True # Saves additional metadata for reporting ) print(f"Notebook executed successfully. Output saved to {output_path}") # Optionally read the output notebook to verify content # import nbformat # with open(output_path, 'r') as f: # nb = nbformat.read(f, as_version=4) # print("\nOutput Notebook Content (first few lines):\n") # for cell in nb.cells: # if cell.cell_type == 'code' and cell.outputs: # for output in cell.outputs: # if 'text' in output.data: # print(output.data['text']['plain']) except pm.exceptions.PapermillExecutionError as e: print(f"Papermill execution failed: {e}") except Exception as e: print(f"An unexpected error occurred: {e}") finally: # Clean up dummy files if os.path.exists('input_notebook.ipynb'): os.remove('input_notebook.ipynb') if os.path.exists('output_notebook.ipynb'): os.remove('output_notebook.ipynb')
papermill --version
Debug
Known issues
breakingPapermill 2.0.0 introduced significant breaking changes, including the removal of `pm.view` and modifications to argument names/defaults in `execute_notebook`. Code written for Papermill 1.x will likely require updates.
fix
Refer to the Papermill 2.0 migration guide for detailed changes. Update function calls and parameter names as needed. Replace `pm.view` functionality with direct notebook inspection or alternative display methods.
affects: 2.0.0 and above
gotchaThe environment where Papermill is run is separate from the kernel environment used by the executed notebook. Ensure the kernel specified in your notebook (e.g., 'python3') has all necessary libraries installed, not just the environment where Papermill itself is installed.
fix
Before executing, verify the target kernel environment (e.g., a specific Conda env or virtualenv) has all dependencies required by the notebook. You can use `pip install -t /path/to/kernel/env-site-packages your-package` or activate the environment before installing.
affects: All versions
gotchaA `papermill.execute_notebook` call might complete successfully even if the underlying notebook cells raise errors. Papermill records the errors within the output notebook but doesn't necessarily propagate them as an exception by default.
fix
To catch notebook-level errors, set `raise_on_error=True` in `execute_notebook`. Alternatively, after execution, programmatically inspect the output notebook for error messages in cell outputs or check the exit code if running via the CLI. For a softer approach, `report_mode=True` adds helpful metadata.
affects: All versions
breakingPapermill 2.x, including the current 2.7.0, requires Python >=3.10. Older versions of Papermill supported earlier Python versions (e.g., 3.6+).
fix
Ensure your Python environment is 3.10 or newer. If you need to use an older Python version, you must downgrade Papermill to a compatible 1.x release, which is not recommended for new projects due to lack of active maintenance.
affects: 2.0.0 and above
Upgrade
Version history
2.7.0latest on PyPI · released Feb 27, 2026
Audit
Dependencies
ipykerneloptionalRequired to execute notebooks within environments where the default 'python3' kernel might not be sufficient or correctly configured. Papermill orchestrates, but a kernel performs the cell execution.
Agent activity
50 hits · last 30 days
node
44
OpenAI (training)
1
Resources