Jupyter Cache provides a defined interface for working with a cache of Jupyter notebooks. It enables execution and caching of notebooks, intelligently re-executing them only when code cells or related metadata have changed, rather than for every minor edit. The library offers both a Command-Line Interface (CLI) and a Python API for managing project notebooks, executing them, and retrieving detailed execution reports including timing statistics and exception tracebacks. It is utilized by projects like Jupyter Book to accelerate document builds by preventing unnecessary re-execution of unchanged notebook content. The current version is 1.0.1, with a release cadence driven by feature enhancements and dependency updates.
pip install jupyter-cacheVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to programmatically initialize a Jupyter Cache, add a notebook to a project, execute it using a local serial executor, and retrieve the executed notebook with its outputs. It first creates a dummy notebook file, then uses the `jupyter_cache` API to manage its lifecycle within the cache.
Upgrade Python to 3.8 or newer. The current minimum required Python version is >=3.9.
Consult the official documentation for the updated CLI commands and Python API methods, specifically looking for 'notebook' and 'project' related functions instead of 'stage' or 'staging'.
Ensure that your notebook's execution environment is stable, all dependencies are pinned, and any non-deterministic operations are controlled (e.g., seeding random number generators). Avoid external dependencies that might change between executions without explicit cache invalidation.
Ensure the library is installed using `pip install jupyter-cache` or `conda install jupyter-cache`. If using a Jupyter Notebook, confirm the kernel is using the correct Python environment where `jupyter-cache` is installed.
Verify that `jupyter-cache` is installed correctly. This error often occurs if `pip install jupyter-cache` was run in an environment not activated in the current terminal, or if the `scripts` directory for your Python installation is not included in your system's PATH environment variable.
Manually execute the notebook completely to ensure all cells have an `execution_count`. Alternatively, when using the `jcache` CLI, you can use the option to skip validity checks (e.g., by answering 'y' to 'continue caching?' or checking for a `--force` or `--skip-validation` option if available).
Check the configured cache path (default is `.jupyter_cache` in the project root) and ensure proper read/write permissions. You can specify the cache path with the `--cache-path` option or `JUPYTERCACHE` environment variable. If issues persist, consider clearing the cache with `jcache project clear` and re-adding/re-executing notebooks.