SpreadMagic
raw JSON → 2.6.1 verified Sat May 09 auth: no python
SpreadMagic is a Python package that provides a magic command for Jupyter and Google Colab to execute Python code in code cells using PyScript within an iframe, enabling interactive spreadsheet-like outputs. Current version 2.6.1, actively maintained.
pip install spreadmagic Common errors
error NameError: name 'load_spreadmagic' is not defined ↓
cause Using old import pattern like 'import spreadmagic' instead of correct import from module.
fix
Use 'from spreadmagic import load_spreadmagic' then 'load_spreadmagic()'.
error UsageError: Cell magic `%%spread` not found ↓
cause Load function not called or called incorrectly before using the magic.
fix
Run 'from spreadmagic import load_spreadmagic' then 'load_spreadmagic()' before using %%spread.
Warnings
gotcha The %%spread magic only works in Jupyter Notebook, JupyterLab, or Google Colab. It will not work in standard Python scripts or IDEs like VS Code (unless using a Jupyter extension). ↓
fix Use in a Jupyter environment only.
deprecated The previous import pattern 'import spreadmagic' or 'from spreadmagic import spread' no longer works. The correct function is load_spreadmagic(). ↓
fix Change to 'from spreadmagic import load_spreadmagic' then call 'load_spreadmagic()'.
gotcha The iframe may not render correctly if the output is too large or contains certain libraries (e.g., matplotlib) due to PyScript limitations. ↓
fix Keep output size reasonable; for plots, consider using traditional Jupyter output instead.
Imports
- load_spreadmagic wrong
import spreadmagiccorrectfrom spreadmagic import load_spreadmagic - %%spread
load_spreadmagic()
Quickstart
from spreadmagic import load_spreadmagic
load_spreadmagic()
%%spread
import pandas as pd
df = pd.DataFrame({'A': [1, 2], 'B': [3, 4]})
df