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 distribution 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.
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
As of SpiceyPy 8.1.2 in mid June 2026, SpiceyPy can be installed into pyodide/pyscript/jupyterlite directly from PyPI using piplite or micropip.
for piplite:
import piplite
await piplite.install("spiceypy")
for micropip:
import micropip
await micropip.install("spiceypy")
for pyscript's json config (plus a psuedo kernel pre-fetch included):
{
"packages": [
"numpy",
"matplotlib",
"spiceypy"
],
"files": {
"https://some/kernel/file.txt": "./file.txt",
}
}
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