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 papermillVerified import paths — ran on the pinned version, not inferred.
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.
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.
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.
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.
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.