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.post4.tar.gz (18.3 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.post4-cp314-cp314-manylinux_2_34_x86_64.whl (182.5 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.34+ x86-64

mojokernel-26.1.0.post4-cp314-cp314-macosx_14_0_arm64.whl (845.3 kB view details)

Uploaded CPython 3.14macOS 14.0+ ARM64

mojokernel-26.1.0.post4-cp313-cp313-manylinux_2_34_x86_64.whl (182.5 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ x86-64

mojokernel-26.1.0.post4-cp313-cp313-macosx_14_0_arm64.whl (845.3 kB view details)

Uploaded CPython 3.13macOS 14.0+ ARM64

mojokernel-26.1.0.post4-cp312-cp312-manylinux_2_34_x86_64.whl (182.5 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

mojokernel-26.1.0.post4-cp312-cp312-macosx_10_13_universal2.whl (845.3 kB view details)

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

mojokernel-26.1.0.post4-cp311-cp311-manylinux_2_34_x86_64.whl (182.5 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

mojokernel-26.1.0.post4-cp311-cp311-macosx_10_9_universal2.whl (845.3 kB view details)

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

mojokernel-26.1.0.post4-cp310-cp310-manylinux_2_34_x86_64.whl (182.5 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.34+ x86-64

mojokernel-26.1.0.post4-cp310-cp310-macosx_11_0_arm64.whl (845.3 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: mojokernel-26.1.0.post4.tar.gz
  • Upload date:
  • Size: 18.3 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.post4.tar.gz
Algorithm Hash digest
SHA256 a0e0a1f7414cc3d6616cdb5cadb8d8d5b6ab2f2b08bb99718fe381f47e986500
MD5 59c1d1132e18e9fb376e7ed7d1895019
BLAKE2b-256 2db362e083f5ff7927532149c0a8028ef43292b8180e3bddf569c8d9caac73bc

See more details on using hashes here.

Provenance

The following attestation bundles were made for mojokernel-26.1.0.post4.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.post4-cp314-cp314-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for mojokernel-26.1.0.post4-cp314-cp314-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 68f700d707146ff7d3f63ecd9f5301616f54dbcddc943fa175af27077257c539
MD5 ae58f4eee8bb2c3bd7d84fbe0cf6e966
BLAKE2b-256 c6f6b8fd19abe1e4dc43df57668c911f114ea857a7bd197b8e95fb8ad1ec1176

See more details on using hashes here.

Provenance

The following attestation bundles were made for mojokernel-26.1.0.post4-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.post4-cp314-cp314-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for mojokernel-26.1.0.post4-cp314-cp314-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 d9f66a11d1608a43270b94d385ca8ff1f3279758c0499cbbbf893bad2ecbc58b
MD5 a90232f8b460a45a44b773733df891ec
BLAKE2b-256 5ad68fa321d4f30c8d43462b5453aa0aa97641e7ac26b98f01d9c7a19f187ebf

See more details on using hashes here.

Provenance

The following attestation bundles were made for mojokernel-26.1.0.post4-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.post4-cp313-cp313-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for mojokernel-26.1.0.post4-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 dc346c6275dfa0900fdefee71262e42cd819a7e819bf7c8a26a66a57c9a11134
MD5 bf57969448b3f2916dcb7b48f101d3d4
BLAKE2b-256 e4eb211148262fd83f2bd281f4f63b8a05e47f7f7595fbba69c724d12f396a3b

See more details on using hashes here.

Provenance

The following attestation bundles were made for mojokernel-26.1.0.post4-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.post4-cp313-cp313-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for mojokernel-26.1.0.post4-cp313-cp313-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 ffd438824a883dd4fb9767eb83924421223c358f1bf6c7380c94370e8551e57a
MD5 12c4ba63140589c7ac2d0d8c084a97e1
BLAKE2b-256 727b1afc5715647659e33c4d44303b49fac9fdec1096d3e05612e8f3ee5e39b0

See more details on using hashes here.

Provenance

The following attestation bundles were made for mojokernel-26.1.0.post4-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.post4-cp312-cp312-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for mojokernel-26.1.0.post4-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 ff9b9287d68461ccd71e488bd165fe4836f82a5acfa0475afa78d9d5f3beade4
MD5 5a686ee539db16d6c1927a3dad23b89d
BLAKE2b-256 c6514bf082c3945fc99a7d6941754fd5b3915e09f6d24f6f9112e112b3884acc

See more details on using hashes here.

Provenance

The following attestation bundles were made for mojokernel-26.1.0.post4-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.post4-cp312-cp312-macosx_10_13_universal2.whl.

File metadata

File hashes

Hashes for mojokernel-26.1.0.post4-cp312-cp312-macosx_10_13_universal2.whl
Algorithm Hash digest
SHA256 11fe04d60e3614b604e40d04ed66f0cdb5b49d783a9e12ffe07a5919caf7e9e6
MD5 8fb45a7224979e9dd2e29af971418225
BLAKE2b-256 ffbc965e99a783f335fe99917d725ff1fd5fb051d4765df152b92e5aaf2326a8

See more details on using hashes here.

Provenance

The following attestation bundles were made for mojokernel-26.1.0.post4-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.post4-cp311-cp311-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for mojokernel-26.1.0.post4-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 afe937df9721f075110de50646ae9408115b7663f06d186f19f9d853257c6090
MD5 6084fa8491e80d6423124dab3a2b19c7
BLAKE2b-256 73a32a3cef22811e8a14a6bfcff2a16eac92d05bfd9abd04b370b01557df75b2

See more details on using hashes here.

Provenance

The following attestation bundles were made for mojokernel-26.1.0.post4-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.post4-cp311-cp311-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for mojokernel-26.1.0.post4-cp311-cp311-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 58da012f491b233b2a342916521578aa2cb7c02305ea4ee4d83c2930af613b09
MD5 b21bcaca82b3e51c0d3591b18c4da6fc
BLAKE2b-256 dd2b52e31071df286ec7b082b41cc75eb7d9f98087646e43f4c4e2294de877cc

See more details on using hashes here.

Provenance

The following attestation bundles were made for mojokernel-26.1.0.post4-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.post4-cp310-cp310-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for mojokernel-26.1.0.post4-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 e8b2710b7d18337c12cb792d3c888b6e52925c82ddf76638bc3489d5889b0947
MD5 c970739596b9bf1afc1ef8d59b0cbda9
BLAKE2b-256 8fb8d0fe8b0673bdf2ff4e1cb423ed82e8e2fb6246b367a9b645113d23e2e877

See more details on using hashes here.

Provenance

The following attestation bundles were made for mojokernel-26.1.0.post4-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.post4-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for mojokernel-26.1.0.post4-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d98f51e3ed47de64242fe4e953981e11be8f37d8b7f5cd3f2b8dbc1fa5af9c50
MD5 71951077106c44ac782fd8d97cece9bc
BLAKE2b-256 7353fdae1ca517563b405a2abdaf2bfeabeb5f8c684c1717079cb1b0bf633f90

See more details on using hashes here.

Provenance

The following attestation bundles were made for mojokernel-26.1.0.post4-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