Mathics3 Extension Module for notebook frontends
This library provides helper functions via a Jupyter Extension to integrate Mathics3 into notebook environments.
Currently, it supports Jupyter, JupyterLite, marimo, and Observable.
For Jupyter, see also the GitHub repository Jupyter Kernel.
Initial setup
Set up your Python environment:
python3 -m venv .venv
source .venv/bin/activate
or using pyenv:
pyenv local 3.14
Running
Next, start Jupyter Notebook:
jupyter notebook # or make run-jupyter-notebook
Alternatively, start Jupyter Lab:
jupyter lab # or make run-jupyter-lab
You should see a URL to connect to:
To access the server, open this file in a browser:
file:/usr/local/share/jupyter/runtime/jpserver-3279554-open.html
Or copy and paste one of these URLs:
http://localhost:8888/tree?token=1833fd2ac0fecd651c3f2d44931bd44c06673dd4701af3ca
http://127.0.0.1:8888/tree?token=1833fd2ac0fecd651c3f2d44931bd44c06673dd4701af3ca
The URLS and file access will be different than the above. Also, remove any browser connections to the URLS, e.g., localhost:8888 or 127.0.0.1:8888, or else you'll see errors.
Inside a standard Python3 Jupyter Kernel (ipykernel), run:
%load_ext mathics3_kernel.frontend.jupyter
After this, entering code in a Notebook cell will be interpreted as Mathics3 input.
Here is a sample notebook that can be used with a local Jupyter installation.
On entering the notebook, you will have to rerun the first cell, which should look like:
%pip install -v Mathics3 Mathics3-notebook-frontends Mathics3-Module-networkx ipywidgets lxml pyocr scikit-image unidecode wordcloud
%load_ext mathics3_kernel.frontend.jupyter
The > button on the menu icon bar, second from the top, does this. Alternatively, the >>
button in that menu will rerun all cells.
If you would like to run Mathics3 in a browser without doing any setup or installation, see Mathics3 Live. The GitHub repository for this is at https://github.com/Mathics3/Mathics3-live
marimo
from mathics3_kernel.frontend.marimo import mathics3
Then run Mathics3 code like so:
mathics3("ArcCos[0]")
See the examples directory for a sample notebook:
marimo edit --sandbox examples/marimo_notebook.py
It also works in marimo's Pyodide-powered online environment; see https://marimo.io/p/@davidar/mathics for an example.
Observable
For other notebook environments, this library provides a generic interface:
from mathics3_kernel.frontend.generic import mathics3
See https://observablehq.com/@davidar/mathics for an example of how this can be used with Observable notebooks. This notebook loads the library with pyodide, then implements a simple interface in JavaScript:
async function mathics3(strings) {
const [type, result] = await py`${mathics3_kernel}(${strings[0]})`
if (type === "code") {
return md`\`\`\`\n${result}\n\`\`\``;
} else if (type === "math") {
return tex.block`${result}`;
} else if (type === "json") {
return JSON.parse(result);
} else if (type === "html") {
return html`${result}`;
} else {
return result;
}
}
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mathics3_notebook_frontends-1.0.1.tar.gz.
File metadata
- Download URL: mathics3_notebook_frontends-1.0.1.tar.gz
- Upload date:
- Size: 27.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f6d13c413f9a7a807a46dc16b5c79de276e29f124196d7185f43b4c139f04280
|
|
| MD5 |
88d9195dc47cbaf2348d3d65f4a4267d
|
|
| BLAKE2b-256 |
34fcacb6204028e034419c8ebca3294b2c10aa42f3a8869794375e57f0808f31
|
File details
Details for the file mathics3_notebook_frontends-1.0.1-py3-none-any.whl.
File metadata
- Download URL: mathics3_notebook_frontends-1.0.1-py3-none-any.whl
- Upload date:
- Size: 27.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
67f3fb479a79a0a2095a0b6476777944d7cebf2fd20415821c362e868516de5d
|
|
| MD5 |
c07cc5f94f4988c627f2333cec850a19
|
|
| BLAKE2b-256 |
f9896496476bd153c5b548aa7be0670aac31d19262e3e87643c88ddffd7d1077
|