Skip to main content

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;
  }
}

Release files for mathics3-notebook-frontends 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mathics3-notebook-frontends 1.0.1
File Size Uploaded
mathics3_notebook_frontends-1.0.1.tar.gz 27.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mathics3-notebook-frontends 1.0.1
File Interpreter ABI Platform
mathics3_notebook_frontends-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 55.3 kB

Release files / mathics3_notebook_frontends-1.0.1.tar.gz

Download URL mathics3_notebook_frontends-1.0.1.tar.gz
Size 27.6 kB
Tags Source
SHA-256 checksum
How to use checksums
f6d13c413f9a7a807a46dc16b5c79de276e29f124196d7185f43b4c139f04280
BLAKE2b-256 checksum
How to use checksums
34fcacb6204028e034419c8ebca3294b2c10aa42f3a8869794375e57f0808f31
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.6

Release files / mathics3_notebook_frontends-1.0.1-py3-none-any.whl

Download URL mathics3_notebook_frontends-1.0.1-py3-none-any.whl
Size 27.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
67f3fb479a79a0a2095a0b6476777944d7cebf2fd20415821c362e868516de5d
BLAKE2b-256 checksum
How to use checksums
f9896496476bd153c5b548aa7be0670aac31d19262e3e87643c88ddffd7d1077
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.6

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page