Skip to content

Pre-Proposal: Project-Local Kernels in Jupyter #133

@mgab

Description

@mgab

Summary

Enhance Jupyter to support project-local kernels, allowing the Jupyter server to detect and load kernels defined within a project directory (e.g. via local .jupyter_kernels/ or kernel.json), instead of relying only on global or user-scoped registrations.

This improves reproducibility and collaboration across languages (Python, R, Julia, etc.), while keeping kernel management explicit and language-agnostic.

Motivation

Jupyter’s current model assumes kernels are installed globally or per-user. This supports one common workflow, but not another that has become increasingly important:

  1. Global / reusable environments
  • A few environments are set up once (e.g. "data-science" Python, "Julia-1.10") and reused across many projects.
  • Jupyter supports this well with global/user kernel.json files.
  1. Project-local environments
  • Each project declares and manages its own isolated runtime and dependencies (pyproject.toml, Project.toml, renv.lock, etc.).
  • Favored for collaboration and reproducibility, but Jupyter requires users to manually create the environment, install the kernel machinery (e.g. ipykernel), and register it globally.
  • This is repetitive, error-prone, and results in cluttered kernel lists.

Modern language ecosystems increasingly encourage per-project environments by default. Jupyter should align with this reality, making project kernels as easy as global ones.

Existing Alternatives and Related Work

  • VS Code Jupyter extension
    • Detects virtual environments and kernels automatically, without requiring global registration.
    • Provides a smoother per-project workflow and demonstrates technical feasibility.
  • nb_conda_kernels
    • Makes Conda environments available as Jupyter kernels.
    • Useful, but limited to Conda/Python.
  • [pyproject-local-kernel](https://github.com/bluss/pyproject-local-kernel)
    • Searches for pyproject.toml, creates a virtualenv, installs ipykernel, and registers a kernel.
    • Python-specific and “magical”: implicitly manages environments, with no per-project control over ipykernel or its dependencies.
  • Status quo (manual ipykernel install)
    • Requires per-user, per-project setup; weak reproducibility; global kernel clutter.

Proposed Approach

  • Discovery mechanism
    • When Jupyter runs in a project directory, search for .jupyter_kernels/<name>/kernel.json or a single kernel.json at project root.
    • These kernels are scoped to the project session and do not pollute global kernel lists.
  • Language-agnostic format
    • Use Jupyter’s existing kernel spec format.
    • Language-specific tools (Poetry, renv, Julia, etc.) may generate kernel specs, but Jupyter itself remains neutral.

Benefits

  • Reproducibility: Kernel definitions live with the project.
  • Collaboration: Teammates get the right kernel after restoring dependencies, no extra steps.
  • Cleaner UX: Project kernels don’t clutter global lists.
  • Language-agnostic: Works across ecosystems.
  • Aligns with existing expectations (e.g. VS Code users).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions