Use additional Python packages#

jupyterlite-pyodide-kernel uses several techniques for loading Python packages at runtime:

Run time#

Installing packages at runtime#

Site users can download and install packages at runtime.

For example, to install snowballstemmer from PyPI:

%pip install -q snowballstemmer

… which translates to:

import piplite

await piplite.install("snowballstemmer")

Note

Some Python packages, such as Jupyter widgets or MIME renderers, may require a frontend extension to also be installed.

See simple extensions for more information.

See also how to ship additional wheels at build time.

Build time#

Bundling additional packages by default#

Patch a distribution with jupyterlite-pyodide-kernel[lock]#

Many wheels can be patched into a Pyodide distribution at build time with the optional [jupyterlite-pyodide-kernel[lock]][adding-wheels-with-jupyterlite-pyodide-kernel-lock].

Build a new distribution with pyodide-build#

The most general way to make additional packages available to import when starting the jupyterlite-pyodide-kernel is to add new packages to a site’s Pyodide distribution.

The process is detailed in the Pyodide documentation.

Once you have added new packages and their dependencies and rebuilt Pyodide, you can configure JupyterLite to use a custom Pyodide distribution.