Loading packages

Author
Affiliation

Aaron Nielsen

White Noise Technology, LLC

Published

March 12, 2025

Abstract

Local python packages can be loaded and used by Pyodide.

Installing packages

All packages must be installed into the pyodide environment. There are two ways to do this.

specify in quarto yaml

In the quarto yaml

pyodide:
  packages:
    - pandas
    - matplotlib
    - r3f

install via micropip

```{pyodide}
import micropip

await micropip.install(<list-of-packages>)
```

Local python packages

Suppose you wrote your own package or made a bug fix to an existing package.

Inertial Navigation Utilities (INU)

Inertial Navigation Utilities (INU) (GitLab) is a pure python package you can pip install by David Woodburn.

pypi packages

In the yaml for this file:

pyodide:
  packages:
    - r3f

Then import the package

Local files

In the yaml from this file:

resources:
  - "_external/inu/inu.py" # path must be relative to this file

Then add the path using sys.path and import

Local packages

Build a wheel

python -m pip install build
python -m build

In the quarto yaml, copy in as a wheel. Set the resources directory or the file won’t be found.

pyodide:
  packages:
    - https://whitenoisetech.codeberg.page/2025-03-12-ddl-pyodide/_external/sgl/dist/sgl-2.1.5-py3-none-any.whl

A tale of Woe

Hosts of problems depending if I used quarto preview to view the file locally or if I put on a web server.

Import the package

Pyodide interactive python web pages with Quarto by Aaron Nielsen is licensed under CC BY-NC-SA 4.0