jupyterlite-pyodide-kernel#
A Python kernel for JupyterLite powered by Pyodide,
Install#
To install the Pyodide kernel labextension and the CLI addons for jupyter lite, run:
pip install jupyterlite-pyodide-kernel
or with conda, mamba, micromamba, etc.
conda install -c conda-forge jupyterlite-pyodide-kernel
For more options see the development install or contributing guide.
Optional Features#
Lock#
Install the [lock] extra for compatible versions of pyodide-lock and
uv, used to add local or PyPI packages and their import name and dependency
information to the Pyodide lockfile:
from PyPI:
jupyterlite-pyodide-kernel[lock]from
conda-forge:jupyterlite-pyodide-kernel-with-lock
Compatibility#
With Jupyter#
status |
|
|
|
|
|
|---|---|---|---|---|---|
stable |
|
|
|
|
- |
stable |
|
|
|
|
- |
stable |
|
|
|
|
- |
stable |
|
|
|
|
- |
stable |
|
|
|
|
- |
stable |
|
|
|
|
- |
stable |
|
|
|
|
- |
stable |
|
|
|
- |
|
Installing the matching version of JupyterLab with your package manager can help ensure
matching labextension assets and kernel dependencies, even though this kernel does not
yet work in a full, jupyter_server-hosted client such as JupyterLab or Notebook.
With Pyodide#
|
|
|
|
|
|
|---|---|---|---|---|---|
|
|
|
|
||
|
|
|
|
||
|
|
|
|
||
|
|
|
|
||
|
|
|
|
||
|
|
|
|
||
|
|
|
|
||
|
|
|
|
||
|
|
|
|
||
|
|
|
|
|
|
Note: the Emscripten version is strict down to the patch version.
Usage#
Once installed, building a JupyterLite site will include a kernel which uses the full Pyodide CDN distribution:
jupyter lite build
The build configuration of the Pyodide distribution, the kernel, and package import
behavior can be configured in jupyter_lite_config.json. Some features can be
configured with CLI aliases and flags. See the full current list by running:
jupyter lite --help
This should show something like the following:
... for configuring the Pyodide distribution
--pyodide=<Unicode>
Local path or URL of a pyodide distribution tarball
Default: ''
Equivalent to: [--PyodideAddon.pyodide_url]
... adding extra wheels, installable at runtime with %pip
--piplite-wheels=<typedtuple-item-1>...
Local paths or URLs of piplite-compatible wheels to copy and index
Default: ()
Equivalent to: [--PipliteAddon.piplite_urls]
.... patching the Pyodide lockfile for automatically imported packages
# flags
--pyodide-lock
Use pyodide-lock and uv to customize pyodide-lock.json
Equivalent to: [--PyodideLockAddon.enabled=True]
--pyodide-lock-no-constrain-extensions
Add ``LiteBuildConfig.federated_extensions`` to constraints
Equivalent to: [--PyodideLockAddon.constrain_extensions=False]
# options
--pyodide-lock-url=<Unicode>
URL of a remote pyodide-lock.json:
https://cdn.jsdelivr.net/pyodide/v0.29.3/full/pyodide-lock.json
Default: ''
Equivalent to: [--PyodideLockAddon.pyodide_lock_url]
--pyodide-lock-wheels=<typedtuple-item-1>...
paths to local wheels or folders to include in pyodide-lock.json
Default: ()
Equivalent to: [--PyodideLockAddon.wheels]
--pyodide-lock-constraints=<typedtuple-item-1>...
PEP-508 specs for Python packages to lock only if required in pyodide-
lock.json; may include ``-r/--requirements`` and ``-g/--group`` relative to
``lite_dir``
Default: ()
Equivalent to: [--PyodideLockAddon.constraints]
--pyodide-lock-lite-constraints=<Unicode>
path relative to ``lite_dir`` to a ``requirements.txt``-style file with
versions of all `none-any.whl` packages from pyodide-lock.json written if
missing, otherwise added to ``constraints`` and left unchanged
Default: ''
Equivalent to: [--PyodideLockAddon.lite_constraints_file]
--pyodide-lock-specs=<typedtuple-item-1>...
PEP-508 specs for Python packages to include in pyodide-lock.json; may
include ``-r/--requirements`` and ``-g/--group`` relative to ``lite_dir``
Default: ()
Equivalent to: [--PyodideLockAddon.specs]
--pyodide-lock-excludes=<typedtuple-item-1>...
extra Python package names to exclude from pyodide-lock.json
Default: ()
Equivalent to: [--PyodideLockAddon.excludes_extra]
--pyodide-lock-prefetch=<typedtuple-item-1>...
extra Python package names from pyodide-lock.json to prefetch while
initializing Pyodide
Default: ()
Equivalent to: [--PyodideLockAddon.prefetch_extra]
Learn more#
⚠️ The documentation for advanced configuration is available from the main JupyterLite documentation site:
Uninstall#
To remove the extension, run:
pip uninstall jupyterlite-pyodide-kernel # or however you installed it
Prerelease Versions#
To install pre-release versions with pip:
pip install --upgrade --pre jupyterlite-pyodide-kernel
Or, similarly for the conda ecosystem, for alpha packages:
conda install \
-c conda-forge/label/jupyterlite_core_alpha \
-c conda-forge/label/jupyterlite_pyodide_kernel_alpha \
-c conda-forge \
jupyterlite-pyodide-kernel
Note:
_betaand_rcpackages would follow a similar channel naming convention
Development Install#
Below is an short overview of getting up and running quickly. Please see the contributing guide for full details.
Development Requirements#
Recommended a Python virtual environment provided by a tool of choice, e.g. one of:
virtualenvmambaconda
Ensure the local development environment has:
gitnodejs 22python >=3.8
Development Quick Start#
git clone https://github.com/jupyterlite/pyodide-kernel
cd pyodide-kernel
npm run quickstart
Then, serve the built demo site, documentation, and test reports with Python’s built-in HTTP server:
jlpm serve