Pyodide (Browser-accessible) SpiceyPy
Danger
This distribution of SpiceyPy is highly experimental! Do not trust it for anything critical. Use at your own risk.
A new Pyodide distribution of SpiceyPy is currently in development.
Pyodide is a port of CPython to WebAssembly, meaning a Python distribution that can run entirely natively within common web browsers. Many popular scientific libraries are already availble for Pyodide, including numpy, scipy, matplotlib, pandas, and many more!
This version of SpiceyPy is essentially the same as the normal desktop Python distributions, as the CSPICE library is compiled to Wasm (web-assembly), allowing the pure python codebase for SpiceyPy to function essentially without modification. The existing test suite for SpiceyPy is used to validate the distribution releases.
It is however slightly limited:
Currently, cyice is unsupported in this pyodide distribution and not included. That may eventually change.
Some functions may not function as expected or return null results, seemingly due to memory limitations and compilation differences.
Pyodide is currently limited to 32bit architecture.
Installation is not possible through PyPI yet, see section below on installation.
Despite these limitations and the danger warning at the top of this page, the Pyodide distribution of SpiceyPy is an incredible new capability with the following potential applications:
Interactive web-based learning and teaching materials. No (to little) setup required.
Embeddable Spice code in websites and FFI with Javascript and other Web APIs.
Easier-to-use supporting information documents for scientific publications.
Wider system and device compatibility, run SpiceyPy on your Phone!
As per the warning above, production use is not recommended.
One of the best places to start using and learning about Pyodide is Jupyter-lite, a browser-native JupyterLab that includes many scientific python packages for use.
Installation
Currently, this distribution of SpiceyPy is not available through PyPI due to the CSPICE dependency.
It is made available through a public GitHub repository https://github.com/AndrewAnnex/spiceypy-wheels-dist.
To install the wheel in Jupyter-lite, access the wheel file using the jsDelivr url corresponding release that will look something like:
https://cdn.jsdelivr.net/gh/AndrewAnnex/spiceypy-wheels-dist@<tag>/spiceypy-<version>-cp313-cp313-pyodide_2025_0_wasm32.whl
Then use piplite like so:
import piplite
await piplite.install("https://cdn.jsdelivr.net/gh/AndrewAnnex/spiceypy-wheels-dist@v8.0.2-dev.2/spiceypy-8.0.2-cp313-cp313-pyodide_2025_0_wasm32.whl")
Usage Example
This page has Pyodide SpiceyPy pre-installed, so no need to run the piplite command above.
Run the cell below by clicking the arrow on the right side when you hover over it with your mouse cursor. It may take a few moments to finish. This software is running on your web browser, no background services (besides CDNs) required.
In the example below we will plot the Venus Rose (Venus's apparent position as seen from Earth over 8 years in the J2000 ecliptic plane.). Try updating the plot below to plot the barycenter of Mars or Mercury!
Various imports and setup:
Load kernels
Specify the dates to sample:
Get the positions vector
Plot it on the ecliptic plane.
Javascript Example
TODO