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.post3.tar.gz (13.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.post3-cp314-cp314-manylinux_2_34_x86_64.whl (178.0 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.34+ x86-64

mojokernel-26.1.0.post3-cp314-cp314-macosx_14_0_arm64.whl (840.9 kB view details)

Uploaded CPython 3.14macOS 14.0+ ARM64

mojokernel-26.1.0.post3-cp313-cp313-manylinux_2_34_x86_64.whl (178.1 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ x86-64

mojokernel-26.1.0.post3-cp313-cp313-macosx_14_0_arm64.whl (840.9 kB view details)

Uploaded CPython 3.13macOS 14.0+ ARM64

mojokernel-26.1.0.post3-cp312-cp312-manylinux_2_34_x86_64.whl (178.0 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

mojokernel-26.1.0.post3-cp312-cp312-macosx_10_13_universal2.whl (840.9 kB view details)

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

mojokernel-26.1.0.post3-cp311-cp311-manylinux_2_34_x86_64.whl (178.0 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

mojokernel-26.1.0.post3-cp311-cp311-macosx_10_9_universal2.whl (840.9 kB view details)

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

mojokernel-26.1.0.post3-cp310-cp310-manylinux_2_34_x86_64.whl (178.0 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.34+ x86-64

mojokernel-26.1.0.post3-cp310-cp310-macosx_11_0_arm64.whl (840.9 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: mojokernel-26.1.0.post3.tar.gz
  • Upload date:
  • Size: 13.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.post3.tar.gz
Algorithm Hash digest
SHA256 234de40ba4d1bc84944be14a18230f17132987dd67606bce0e00edfb77cb407e
MD5 2ac624a3efa23f5f8f8223f1c8255333
BLAKE2b-256 d097a2b87ca4859c62af3aeca6486ff2b31af93423118b3c4df498850e96f077

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mojokernel-26.1.0.post3-cp314-cp314-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 282649c1063052197a8181e652f7b1378064137e01b23ebcc21ae1c103400581
MD5 dcd6711ca25b6842c174f933c75e6491
BLAKE2b-256 4f1e2e490f2ebce4ea82c08a863729fb8d1415c089d953a5afcef5d90fd970ae

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mojokernel-26.1.0.post3-cp314-cp314-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 edcfcb4914846f0a3910db2ef7c56aeb30f11be6df21caf0917cc5a54c9b1a65
MD5 a44f19219217a14a791a97a3bfa8a970
BLAKE2b-256 2dd6a26e0a36bebf2d12e57aca3124430461ffe96e7ba2884673ecf8a1d7f212

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mojokernel-26.1.0.post3-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 a4f871f2eef3cf8b1a06535a74d5efbf3c6c01c04b5f252bbd7b740baaef20e5
MD5 4fde48016497baa3ca369e2749767a65
BLAKE2b-256 06f691766e1ebbdf3dff8e3647b2e38f2afbecdbae57c409adf195e2f0b092ec

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mojokernel-26.1.0.post3-cp313-cp313-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 cc45edff9ce3c54849d3b17dcb9c8ef57010ccc72f25330c6bf0bdb19d26f07f
MD5 6b3fcc8df601ca4577c7dc8def1f2e03
BLAKE2b-256 5f13ec5d983a44639773b6f49749d7e986a3bad5ab174a44cc481975dede7ca6

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mojokernel-26.1.0.post3-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 2523c350a4a018917031dd11f8f5f7667d548d33551341ded39e9ee8359c0e0a
MD5 8fa051f371e98fe1086bc234683256fc
BLAKE2b-256 e8791dc4b1a05ee7718e7df6c1c2dddf551bcbd75831724f077990d80aca9132

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mojokernel-26.1.0.post3-cp312-cp312-macosx_10_13_universal2.whl
Algorithm Hash digest
SHA256 37a88f5630f7aea1dbed061258d8944934ce8b70f1ea0d159bf7e2175a57479a
MD5 ea4c3f7d4341efde0125ce1ac47ab83e
BLAKE2b-256 6569f95229102df58a849799c2664d1427145525f5a0d1d8b8e1dce2d6c5e52c

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mojokernel-26.1.0.post3-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 880cdf48b5ab82b9dd0945b4b342aea128a03698a7a75d954875fb4f49f17907
MD5 87ef643afdeaedc5ad683fec7f8b9969
BLAKE2b-256 54ea6300a81570971c850cd355447549a7641392171147160002c8d64e142c0f

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mojokernel-26.1.0.post3-cp311-cp311-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 92f5913fbbbe980febf7fc2145c617f85fed6fd09f744ba540b91379fd34df6f
MD5 822d2121ba442df8f4276e17d9759e00
BLAKE2b-256 5942f6c3e9ca3c9a38c7482814a986cb34a2c92b438d8c2b7b5b5787bdfb0fcf

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mojokernel-26.1.0.post3-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 403abb8b706e02480d1cd5b4f8aee1c42b39896a8f5216f9e26e1d3e91801ae4
MD5 621385cd6c357f35f1689c5a6f8abd37
BLAKE2b-256 f2c308f47d03c97d1d536e0f01b13f2ad135ab871985aa722f793731781f7d7c

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mojokernel-26.1.0.post3-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c702680dab630ba106f9a08de21919373f44b358c453b7639a8a37c296f6c6df
MD5 c9eeceb4c1c7421947a9bcb9c0f1edd4
BLAKE2b-256 f42a67608bf87470dac96989cdf05c4958d7067cc66369d111661debd1665730

See more details on using hashes here.

Provenance

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