modular / modular/modular

[BUG] Jupyter Notebook fails to load mojo kernel

Open
#3,304 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug Initiative: REPL/Jupyter mojo mojo-repo
Dominant language
Mojo
Stars
29.8k
Forks
3.2k
PR merge metrics
No merged PRs in 30d

Description

Bug description

After loading any .ipynb file from the mojo/examples/notebooks directory and selecting the mojo kernel, Jupyter complains about "Kernel could not be started. Kernel died unexpectedly." This happens with both JupyterLab and VSCode. Here is the log from VSCode.

Visual Studio Code (1.91.1, undefined, desktop)
Jupyter Extension Version: 2024.6.0.
Python Extension Version: 2024.10.0.
Pylance Extension Version: 2024.7.1.
Platform: darwin (arm64).
Workspace folder ~/IdeaProjects/mojo, Home = /Users/tallinn
17:29:14.306 [info] Telemetry level is off
17:29:14.306 [info] Experiments are disabled, only manually opted experiments are active.
17:29:31.664 [info] Starting Kernel (Mojo) for '~/IdeaProjects/mojo/examples/notebooks/Mandelbrot.ipynb' (disableUI=true)
17:29:31.687 [info] Launching Raw Kernel Mojo # /Users/~/.modular/pkg/packages.modular.com_mojo/venv/bin/python
17:29:31.689 [info] Process Execution: ~/.modular/pkg/packages.modular.com_mojo/venv/bin/python /Users/~/Library/Jupyter/kernels/mojo-jupyter-kernel/mojokernel.py -f /Users/~/Library/Jupyter/runtime/kernel-v2-70840xQK8DQHqhW2w.json --modular-home /Users/~/.modular --mojo-config-section mojo
    > cwd: //Users/~/IdeaProjects/mojo/examples/notebooks
17:29:32.020 [error] Disposing kernel process due to an error Error: Der Kernel wurde unerwartet beendet. Fehler: ... Weitere Informationen finden Sie im Jupyter-[Protokoll](command:jupyter.viewOutput).
    > Kernel Id = .mojo-jupyter-kernel./Users/~/.modular/pkg/packages.modular.com_mojo/venv/python././users/~/.modular/pkg/packages.modular.com_mojo/venv/bin/python#/users/~/library/jupyter/kernels/mojo-jupyter-kernel/mojokernel.py#-f#{connection_file}#--modular-home#/users/~/.modular#--mojo-config-section#mojo
    > at ChildProcess.<anonymous> (/Users/~/.vscode/extensions/ms-toolsai.jupyter-2024.6.0-darwin-arm64/dist/extension.node.js:299:44339)
    > stdErr = 
17:29:32.020 [error] 
17:29:32.020 [error] Failed to connect raw kernel session: Error: Der Kernel wurde unerwartet beendet. Fehler: ... Weitere Informationen finden Sie im Jupyter-[Protokoll](command:jupyter.viewOutput).
17:29:32.020 [error] Failed to connect raw kernel session: Error: Der Kernel wurde unerwartet beendet. Fehler: ... Weitere Informationen finden Sie im Jupyter-[Protokoll](command:jupyter.viewOutput).
17:29:32.020 [warn] Failed to shutdown kernel, .mojo-jupyter-kernel./Users/~/.modular/pkg/packages.modular.com_mojo/venv/python././users/~/.modular/pkg/packages.modular.com_mojo/venv/bin/python#/users/~/library/jupyter/kernels/mojo-jupyter-kernel/mojokernel.py#-f#{connection_file}#--modular-home#/users/~/.modular#--mojo-config-section#mojo TypeError: Cannot read properties of undefined (reading 'dispose')
    at R_.shutdown (/Users/~/.vscode/extensions/ms-toolsai.jupyter-2024.6.0-darwin-arm64/dist/extension.node.js:304:13629)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at A_.shutdown (/Users/~/.vscode/extensions/ms-toolsai.jupyter-2024.6.0-darwin-arm64/dist/extension.node.js:304:22107)
17:29:32.021 [warn] Error occurred while trying to start the kernel, options.disableUI=true Error: Der Kernel wurde unerwartet beendet. Fehler: ... Weitere Informationen finden Sie im Jupyter-[Protokoll](command:jupyter.viewOutput).
    > Kernel Id = .mojo-jupyter-kernel./Users/~/.modular/pkg/packages.modular.com_mojo/venv/python././users/~/.modular/pkg/packages.modular.com_mojo/venv/bin/python#/users/~/library/jupyter/kernels/mojo-jupyter-kernel/mojokernel.py#-f#{connection_file}#--modular-home#/users/~/.modular#--mojo-config-section#mojo
    > at ChildProcess.<anonymous> (/Users/~/.vscode/extensions/ms-toolsai.jupyter-2024.6.0-darwin-arm64/dist/extension.node.js:299:44339)
    > stdErr = 

macOS Sonoma 14.5, Mac mini M1

mojo 24.4.0 (2cb57382)

modular 0.8.0 (39a426b5)

Steps to reproduce
  • Include relevant code snippet or link to code that did not work as expected.
  • If applicable, add screenshots to help explain the problem.
  • If using the Playground, name the pre-existing notebook that failed and the steps that led to failure.
  • Include anything else that might help us debug the issue.
System information
- What OS did you do install Mojo on ?
- Provide version information for Mojo by pasting the output of `mojo -v`
- Provide Modular CLI version by pasting the output of `modular -v`

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the failure with examples/notebooks/Mandelbrot.ipynb in JupyterLab or VSCode, using the launch command shown in the log. Read the mojo-jupyter-kernel/mojokernel.py entry point and inspect how its --modular-home and --mojo-config-section arguments are used. Done means the Mojo kernel starts and the notebook loads on the reported macOS setup.

Written by the indexing model from the issue text.

Assessment

Tech stack
jupyter-notebook, python
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.