Skip to main content

Jupyter kernel for Mojo

Project description

mojokernel

A Jupyter kernel for Mojo. Supports full variable persistence, function/struct definitions, and error handling across notebook cells.

NB: This is not an official Modular project. It's created by Jeremy Howard from Answer.AI and uses undocumented private symbols from mojo in ways that might turn out to be flaky or disappear in a future version. If Modular releases an official kernel that provides the same functionality, we'll archive this one and update these docs to point at that instead.

Install

We recommend uv which handles the Mojo package index automatically:

uv pip install mojokernel
mojokernel install --sys-prefix

With pip, install Mojo first (it's hosted on a separate index that pip can't discover automatically):

pip install modular --extra-index-url https://modular.gateway.scarf.sh/simple/
pip install mojokernel
mojokernel install --sys-prefix

Then select "Mojo" in Jupyter's kernel picker.

The pre-built wheel includes a compiled C++ server that talks directly to Mojo's LLDB -- no text parsing, fast and reliable. If the server binary isn't available for your platform, the kernel falls back to a pexpect-based engine that wraps mojo repl.

Pexpect fallback

The pexpect engine is used automatically if the C++ server binary isn't present (e.g. when installing from the sdist). It spawns mojo repl and parses its output. To force pexpect mode:

MOJO_KERNEL_ENGINE=pexpect jupyter lab

Building from source

To build the C++ server yourself (e.g. for development or an unsupported platform):

brew install llvm   # macOS; on Linux: apt install llvm-18-dev liblldb-18-dev
tools/build_server.sh

PTY server (backup)

A third engine variant (server/repl_server_pty.cpp) uses SBDebugger::RunREPL() with PTY I/O redirection. This is a fallback in case the EvaluateExpression approach breaks in a future Modular release.

Releases

mojokernel wheels are built against a specific Mojo version. Install the version matching your Mojo:

# Check your Mojo version
mojo --version          # e.g. "Mojo 0.26.1.0 (156d3ac6)" → version 26.1.0

# Install matching mojokernel
uv pip install mojokernel==26.1.0

Publishing a new release

The wheel version is determined automatically from the latest Mojo release (via mojokernel/_version.py). No manual version bumping needed.

When Mojo publishes a new version:

  1. Go to Actions > "Build and publish wheels" > Run workflow
  2. Set publish: true to upload to PyPI

The CI installs the latest Mojo, builds the C++ server, and produces platform wheels tagged with the detected Mojo version. Wheels are built for macOS (Apple Silicon) and Linux (x86_64).

Testing

uv pip install -e .
pytest -q

Architecture

mojokernel/
  kernel.py              -- Jupyter kernel (ipykernel subclass)
  engines/
    base.py              -- ExecutionResult dataclass
    pexpect_engine.py    -- pexpect-based engine (default)
    server_engine.py     -- C++ server engine client
server/
  repl_server.cpp        -- C++ server (EvaluateExpression + REPL mode)
  repl_server_pty.cpp    -- PTY-based backup server
  mojo_repl.cpp          -- thin REPL wrapper (RunREPL)
  json.hpp               -- nlohmann/json
tests/
  test_pexpect_engine.py -- pexpect engine tests
  test_server_execute.py -- server engine tests
  test_kernel.py         -- kernel integration tests
tools/
  build_server.sh        -- compile C++ binaries
  server_exec.py         -- send code to server (debugging tool)
  test.sh                -- run pytest

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mojokernel-26.1.0.post2.tar.gz (13.2 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

mojokernel-26.1.0.post2-cp314-cp314-manylinux_2_34_x86_64.whl (177.9 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.34+ x86-64

mojokernel-26.1.0.post2-cp314-cp314-macosx_14_0_arm64.whl (840.7 kB view details)

Uploaded CPython 3.14macOS 14.0+ ARM64

mojokernel-26.1.0.post2-cp313-cp313-manylinux_2_34_x86_64.whl (177.9 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ x86-64

mojokernel-26.1.0.post2-cp313-cp313-macosx_14_0_arm64.whl (840.7 kB view details)

Uploaded CPython 3.13macOS 14.0+ ARM64

mojokernel-26.1.0.post2-cp312-cp312-manylinux_2_34_x86_64.whl (177.9 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

mojokernel-26.1.0.post2-cp312-cp312-macosx_10_13_universal2.whl (840.7 kB view details)

Uploaded CPython 3.12macOS 10.13+ universal2 (ARM64, x86-64)

mojokernel-26.1.0.post2-cp311-cp311-manylinux_2_34_x86_64.whl (177.9 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

mojokernel-26.1.0.post2-cp311-cp311-macosx_10_9_universal2.whl (840.7 kB view details)

Uploaded CPython 3.11macOS 10.9+ universal2 (ARM64, x86-64)

mojokernel-26.1.0.post2-cp310-cp310-manylinux_2_34_x86_64.whl (177.9 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.34+ x86-64

mojokernel-26.1.0.post2-cp310-cp310-macosx_11_0_arm64.whl (840.7 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

Details for the file mojokernel-26.1.0.post2.tar.gz.

File metadata

  • Download URL: mojokernel-26.1.0.post2.tar.gz
  • Upload date:
  • Size: 13.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for mojokernel-26.1.0.post2.tar.gz
Algorithm Hash digest
SHA256 e1fa1d26a5828ecd2f1645be6d6c72bcf082d192a6119f6d60f18609b7194276
MD5 07218d78a27decbcf7a41798c6b78b12
BLAKE2b-256 fe203ccc3dcab66b50daa1822d496dd8ee480799f82b4523293e34537f10b8f4

See more details on using hashes here.

Provenance

The following attestation bundles were made for mojokernel-26.1.0.post2.tar.gz:

Publisher: release.yml on AnswerDotAI/mojokernel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mojokernel-26.1.0.post2-cp314-cp314-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for mojokernel-26.1.0.post2-cp314-cp314-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 4163fbe6a8e98ff7d1cbcfebfdcf31a4e6aed94838a2cfc3694ed5b88f6b18c7
MD5 1abf85f257b72d09fe441a5b8ebebebc
BLAKE2b-256 7d0ef02b01cbb32bb1e171b3b7605e6b556bad9ba2343104f48251a288599f12

See more details on using hashes here.

Provenance

The following attestation bundles were made for mojokernel-26.1.0.post2-cp314-cp314-manylinux_2_34_x86_64.whl:

Publisher: release.yml on AnswerDotAI/mojokernel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mojokernel-26.1.0.post2-cp314-cp314-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for mojokernel-26.1.0.post2-cp314-cp314-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 0236e1a3a4fd119637783419575219385fc0d752b98702a15a76354519c425e7
MD5 13aa6770b9073b7c95d161c91feb0838
BLAKE2b-256 32712a8f39607fad65352faf87914fc21b9eb875ea67cd4c3974a8ae1c50c26b

See more details on using hashes here.

Provenance

The following attestation bundles were made for mojokernel-26.1.0.post2-cp314-cp314-macosx_14_0_arm64.whl:

Publisher: release.yml on AnswerDotAI/mojokernel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mojokernel-26.1.0.post2-cp313-cp313-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for mojokernel-26.1.0.post2-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 ac3cbfea03c3b7b5b61edd14bcc10130b9b0cfa66f3aa01c3a22f0a49ee5045e
MD5 259becd6054355c70dc7acc0fdec3e1b
BLAKE2b-256 40b574c0a5dd45f1a4bfc2c93ac3eaf130db3c7c7a2ff8c3416fc906521432d6

See more details on using hashes here.

Provenance

The following attestation bundles were made for mojokernel-26.1.0.post2-cp313-cp313-manylinux_2_34_x86_64.whl:

Publisher: release.yml on AnswerDotAI/mojokernel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mojokernel-26.1.0.post2-cp313-cp313-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for mojokernel-26.1.0.post2-cp313-cp313-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 8c2731769d3f48f61ce6de64fc6314818213aaaa67de67eb0a43892b0d26ab06
MD5 658b25a8ab71c88edba217b289e930ba
BLAKE2b-256 b025aeeed2c937a3930f7723890554cf880aeb682d4745ffd18ed994931dc1f6

See more details on using hashes here.

Provenance

The following attestation bundles were made for mojokernel-26.1.0.post2-cp313-cp313-macosx_14_0_arm64.whl:

Publisher: release.yml on AnswerDotAI/mojokernel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mojokernel-26.1.0.post2-cp312-cp312-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for mojokernel-26.1.0.post2-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 422f12dcf4f61ef76274b2ccf071954dbd2877be0f04d38b09d13a9805946500
MD5 b1fa56c43f9b67ae19eedff2e0c6ebdd
BLAKE2b-256 04426c99af0e76807eade1aa7cfa3d935700c8ab0159606d119079bcbc631fde

See more details on using hashes here.

Provenance

The following attestation bundles were made for mojokernel-26.1.0.post2-cp312-cp312-manylinux_2_34_x86_64.whl:

Publisher: release.yml on AnswerDotAI/mojokernel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mojokernel-26.1.0.post2-cp312-cp312-macosx_10_13_universal2.whl.

File metadata

File hashes

Hashes for mojokernel-26.1.0.post2-cp312-cp312-macosx_10_13_universal2.whl
Algorithm Hash digest
SHA256 efd745981d106287a36a292065b6f205b33b39b768d8c04019ccde3e1146e94a
MD5 363ed6947483cb0ab6601d2020daac13
BLAKE2b-256 c2bb4b388f10f78de798b1cac573da23e96f617e52f9ba88331c35e73303d9fe

See more details on using hashes here.

Provenance

The following attestation bundles were made for mojokernel-26.1.0.post2-cp312-cp312-macosx_10_13_universal2.whl:

Publisher: release.yml on AnswerDotAI/mojokernel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mojokernel-26.1.0.post2-cp311-cp311-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for mojokernel-26.1.0.post2-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 559b6b46af3f23634b8659af5a2155c43d29b06f7fd333a5e95c5f73934e2ef1
MD5 648487253fec335fb7ebdd56a5b1e544
BLAKE2b-256 e16ed9d862f2e928fe4991c22b9294f070fc50a65f1068db0614ae12c51fab5f

See more details on using hashes here.

Provenance

The following attestation bundles were made for mojokernel-26.1.0.post2-cp311-cp311-manylinux_2_34_x86_64.whl:

Publisher: release.yml on AnswerDotAI/mojokernel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mojokernel-26.1.0.post2-cp311-cp311-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for mojokernel-26.1.0.post2-cp311-cp311-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 830805b49d5d2d676ed5ac33ba4e1731bca00e431d17cabd45066976b27877ae
MD5 ef2962eeed9fe76cb3b3bc5c2b08e4a3
BLAKE2b-256 8fd384505f97ab10467fe4e9675d382ff78d42736a92ad45c426d79571b8f89f

See more details on using hashes here.

Provenance

The following attestation bundles were made for mojokernel-26.1.0.post2-cp311-cp311-macosx_10_9_universal2.whl:

Publisher: release.yml on AnswerDotAI/mojokernel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mojokernel-26.1.0.post2-cp310-cp310-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for mojokernel-26.1.0.post2-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 e7067931dfd000f1857cc17c12422e0d9a7e5d43bc8738944f9250772e3b54ab
MD5 5c5fc2d43f222e53a477ba6c5af3112b
BLAKE2b-256 8b42691114ba511b2485946c93dc13d34594904128d51d9aa8ff6d0d55e34677

See more details on using hashes here.

Provenance

The following attestation bundles were made for mojokernel-26.1.0.post2-cp310-cp310-manylinux_2_34_x86_64.whl:

Publisher: release.yml on AnswerDotAI/mojokernel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mojokernel-26.1.0.post2-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for mojokernel-26.1.0.post2-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 72a40e3d45f3e7233a9c60e41f0d4e9d992128fda096c0d482a0c88a94d882a0
MD5 15972ad558717d4b4f53f4753449c3be
BLAKE2b-256 a87452ea495ae4cfd0bc6db282fb61eb4037c8b89de63184b42434eff3534d12

See more details on using hashes here.

Provenance

The following attestation bundles were made for mojokernel-26.1.0.post2-cp310-cp310-macosx_11_0_arm64.whl:

Publisher: release.yml on AnswerDotAI/mojokernel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page