-
Notifications
You must be signed in to change notification settings - Fork 66
Open
Labels
Description
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:
- 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.jsonfiles.
- 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.jsonor a singlekernel.jsonat project root. - These kernels are scoped to the project session and do not pollute global kernel lists.
- When Jupyter runs in a project directory, search for
- 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).