Sagemath kernel dies in existing Jupyter notebook (and VScode)

asked 2025-12-20 17:57:41 +0100

alessio_sgubin gravatar image

Hi there, I have recently upgraded my laptop, running Linux Ubuntu 24.04.3 LTS. I have installed Sagemath from Source Code (following all the steps and installing the recommended packages).

Sage works just fine standalone and also the Sagemath kernel in Jupyter when invoked using the command sage -n jupyter. However, if I start the Jupyter notebook app and try running some code from a .ipynb file, the Sagemath kernel dies with the following log:

[I 2025-12-20 17:35:02.145 ServerApp] Skipped non-installed server(s): basedpyright, bash-language-server, dockerfile-language-server-nodejs, javascript-typescript-langserver, jedi-language-server, julia-language-server, pyrefly, pyright, python-language-server, python-lsp-server, r-languageserver, sql-language-server, texlab, typescript-language-server, unified-language-server, vscode-css-languageserver-bin, vscode-html-languageserver-bin, vscode-json-languageserver-bin, yaml-language-server /home/alessio-sgubin/.local/share/pipx/venvs/jupyter/bin/python: Error while finding module specification for 'sage.repl.ipython_kernel' (ModuleNotFoundError: No module named 'sage')

[I 2025-12-20 17:35:11.928 ServerApp] Kernel started: 49c7ed82-bc90-427d-8242-531fc4dd01cf [I 2025-12-20 17:35:14.896 ServerApp] AsyncIOLoopKernelRestarter: restarting kernel (1/5), new random ports /home/alessio-sgubin/.local/share/pipx/venvs/jupyter/bin/python: Error while finding module specification for 'sage.repl.ipython_kernel' (ModuleNotFoundError: No module named 'sage')

[I 2025-12-20 17:35:17.911 ServerApp] AsyncIOLoopKernelRestarter: restarting kernel (2/5), new random ports /home/alessio-sgubin/.local/share/pipx/venvs/jupyter/bin/python: Error while finding module specification for 'sage.repl.ipython_kernel' (ModuleNotFoundError: No module named 'sage')

[I 2025-12-20 17:35:20.924 ServerApp] AsyncIOLoopKernelRestarter: restarting kernel (3/5), new random ports /home/alessio-sgubin/.local/share/pipx/venvs/jupyter/bin/python: Error while finding module specification for 'sage.repl.ipython_kernel' (ModuleNotFoundError: No module named 'sage')

[I 2025-12-20 17:35:23.938 ServerApp] AsyncIOLoopKernelRestarter: restarting kernel (4/5), new random ports /home/alessio-sgubin/.local/share/pipx/venvs/jupyter/bin/python: Error while finding module specification for 'sage.repl.ipython_kernel' (ModuleNotFoundError: No module named 'sage')

[I 2025-12-20 17:35:26.952 ServerApp] AsyncIOLoopKernelRestarter: restarting kernel (5/5), new random ports /home/alessio-sgubin/.local/share/pipx/venvs/jupyter/bin/python: Error while finding module specification for 'sage.repl.ipython_kernel' (ModuleNotFoundError: No module named 'sage')

A different error appears when I try to use the Jupyter notebook from VScode:

Failed to start the Kernel. View Jupyter log for further details.

The log file says the following:

Visual Studio Code (1.107.1, undefined, desktop)

Jupyter Extension Version: 2025.9.1.

Python Extension Version: 2025.20.1.

Python Environment Extension Version: 1.14.0.

Pylance Extension Version: 2025.10.4.

Platform: linux (x64).

Home = /home/alessio-sgubin

Temp Storage folder ~/.config/Code/User/globalStorage/ms-toolsai.jupyter/version-2025.9.1

Workspace folder ~/Desktop/Repositories/tau_functions

17:39:40.752 [info] Starting Kernel (SageMath 10.8) for '~/Desktop/Repositories/tau_functions/symm_func_Jack.ipynb' (disableUI=true)

17:39:41.103 [info] Launching Raw Kernel SageMath 10.8 # ~/sage/sage/sage

17:39:41.128 [info] Process Execution: ~/sage/sage/sage python -m sage.repl.ipython_kernel -f /run/user/1000/jupyter/runtime/kernel-v3079493e439c285045fd867873bbe5e7daac0ea7e.json cwd: ~/Desktop/Repositories/tau_functions

17:39:41.297 [error] Widget Error: Failed to access CDN http://unpkg.com after 0 attempt(s), TypeError: Failed to fetch

17:39:41.694 [error] Disposing kernel process due to an error Error: The kernel died. Error: python3: can't open file '~/Desktop/Repositories/tau_functions/python': [Errno 2] No such file or directory... View Jupyter log for further details. Kernel Id = .sagemath.~/sage/sage/sage./.~/sage/sage/sage#python#-m#sage.repl.ipython_kernel#-f#{connection_file} at ChildProcess.<anonymous> (~/.vscode/extensions/ms-toolsai.jupyter-2025.9.1-linux-x64/dist/extension.node.js:304:45805) stdErr = python3: can't open file '~/Desktop/Repositories/tau_functions/python': [Errno 2] No such file or directory

17:39:41.699 [error] Failed to connect raw kernel session: Error: The kernel died. Error: python3: can't open file '~/Desktop/Repositories/tau_functions/python': [Errno 2] No such file or directory... View Jupyter log for further details.

17:39:41.699 [error] Failed to connect raw kernel session: Error: The kernel died. Error: python3: can't open file '~/Desktop/Repositories/tau_functions/python': [Errno 2] No such file or directory... View Jupyter log for further details.

17:39:41.700 [warn] Failed to shutdown kernel, .sagemath.~/sage/sage/sage./.~/sage/sage/sage#python#-m#sage.repl.ipython_kernel#-f#{connection_file} [TypeError: Cannot read properties of undefined (reading 'dispose') at JT.shutdown (~/.vscode/extensions/ms-toolsai.jupyter-2025.9.1-linux-x64/dist/extension.node.js:309:13632) at process.processTicksAndRejections (node:internal/process/task_queues:105:5) at async qT.shutdown (~/.vscode/extensions/ms-toolsai.jupyter-2025.9.1-linux-x64/dist/extension.node.js:309:22453)]

17:39:41.704 [warn] Error occurred while trying to start the kernel, options.disableUI=true Error: The kernel died. Error: python3: can't open file '~/Desktop/Repositories/tau_functions/python': [Errno 2] No such file or directory... View Jupyter log for further details. Kernel Id = .sagemath.~/sage/sage/sage./.~/sage/sage/sage#python#-m#sage.repl.ipython_kernel#-f#{connection_file} at ChildProcess.<anonymous> (~/.vscode/extensions/ms-toolsai.jupyter-2025.9.1-linux-x64/dist/extension.node.js:304:45805) stdErr = python3: can't open file '~/Desktop/Repositories/tau_functions/python': [Errno 2] No such file or directory

17:39:43.089 [warn] Duplicate kernel found SageMath 10.8 python in ~/.local/share/jupyter/kernels/sagemath/kernel.json

17:39:43.091 [warn] Disposing old controller startUsingLocalKernelSpec:'.sagemath.~/sage/sage/sage./.~/sage/sage/sage#python#-m#sage.repl.ipython_kernel#-f#{connection_file} (Interactive)' for view = 'interactive'

17:39:43.092 [warn] Deleting controller .sagemath.~/sage/sage/sage./.~/sage/sage/sage#python#-m#sage.repl.ipython_kernel#-f#{connection_file} as it is associated with a connection that has been deleted startUsingLocalKernelSpec:.sagemath.~/sage/sage/sage./.~/sage/sage/sage#python#-m#sage.repl.ipython_kernel#-f#{connection_file}

17:39:48.106 [info] Dispose Kernel '~/Desktop/Repositories/tau_functions/symm_func_Jack.ipynb' associated with '~/Desktop/Repositories/tau_functions/symm_func_Jack.ipynb'

17:39:48.110 [info] Starting Kernel (SageMath 10.8) for '~/Desktop/Repositories/tau_functions/symm_func_Jack.ipynb' (disableUI=true)

17:39:48.129 [info] Launching Raw Kernel SageMath 10.8 # python

17:39:48.142 [info] Process Execution: /python -m sage.repl.ipython_kernel -f /run/user/1000/jupyter/runtime/kernel-v36736b922437e6f93152275f8f271848566874483.json cwd: ~/Desktop/Repositories/tau_functions

17:39:48.144 [error] Kernel died [Error: spawn python ENOENT at ChildProcess._handle.onexit (node:internal/child_process:285:19) at onErrorNT (node:internal/child_process:483:16) at process.processTicksAndRejections (node:internal/process/task_queues:90:21)] { errno: -2, code: 'ENOENT', syscall: 'spawn python', path: 'python', spawnargs: [ '-m', 'sage.repl.ipython_kernel', '-f', '/run/user/1000/jupyter/runtime/kernel-v36736b922437e6f93152275f8f271848566874483.json' ] }

17:39:48.145 [error] Disposing kernel process due to an error [Error: spawn python ENOENT at ChildProcess._handle.onexit (node:internal/child_process:285:19) at onErrorNT (node:internal/child_process:483:16) at process.processTicksAndRejections (node:internal/process/task_queues:90:21)] { errno: -2, code: 'ENOENT', syscall: 'spawn python', path: 'python', spawnargs: [ '-m', 'sage.repl.ipython_kernel', '-f', '/run/user/1000/jupyter/runtime/kernel-v36736b922437e6f93152275f8f271848566874483.json' ] }

17:39:48.146 [error]

17:39:48.148 [error] Failed to connect raw kernel session: Error: The kernel died. Error: ... View Jupyter log for further details.

17:39:48.148 [error] Failed to connect raw kernel session: Error: The kernel died. Error: ... View Jupyter log for further details.

17:39:48.149 [warn] Failed to shutdown kernel, .sagemath./python./.python#-m#sage.repl.ipython_kernel#-f#{connection_file} [TypeError: Cannot read properties of undefined (reading 'dispose') at JT.shutdown (~/.vscode/extensions/ms-toolsai.jupyter-2025.9.1-linux-x64/dist/extension.node.js:309:13632) at process.processTicksAndRejections (node:internal/process/task_queues:105:5) at async qT.shutdown (~/.vscode/extensions/ms-toolsai.jupyter-2025.9.1-linux-x64/dist/extension.node.js:309:22453)]

17:39:48.150 [warn] Error occurred while trying to start the kernel, options.disableUI=false Error: The kernel died. Error: ... View Jupyter log for further details. Kernel Id = .sagemath./python./.python#-m#sage.repl.ipython_kernel#-f#{connection_file} at new n (~/.vscode/extensions/ms-toolsai.jupyter-2025.9.1-linux-x64/dist/extension.node.js:62:51941) originalException = Error: spawn python ENOENT stdErr =

17:39:48.151 [warn] Kernel Error, context = start Error: The kernel died. Error: ... View Jupyter log for further details. Kernel Id = .sagemath./python./.python#-m#sage.repl.ipython_kernel#-f#{connection_file} at new n (~/.vscode/extensions/ms-toolsai.jupyter-2025.9.1-linux-x64/dist/extension.node.js:62:51941) originalException = Error: spawn python ENOENT stdErr =

17:39:48.167 [info] Dispose Kernel '~/Desktop/Repositories/tau_functions/symm_func_Jack.ipynb' associated with '~/Desktop/Repositories/tau_functions/symm_func_Jack.ipynb'

17:39:48.168 [error] Error in notebook cell execution Error: The kernel died. Error: ... View Jupyter log for further details. Kernel Id = .sagemath./python./.python#-m#sage.repl.ipython_kernel#-f#{connection_file} at new n (~/.vscode/extensions/ms-toolsai.jupyter-2025.9.1-linux-x64/dist/extension.node.js:62:51941) originalException = Error: spawn python ENOENT stdErr =

17:39:48.170 [error] Error in execution (get message for cell) Error: The kernel died. Error: ... View Jupyter log for further details. Kernel Id = .sagemath./python./.python#-m#sage.repl.ipython_kernel#-f#{connection_file} at new n (~/.vscode/extensions/ms-toolsai.jupyter-2025.9.1-linux-x64/dist/extension.node.js:62:51941) originalException = Error: spawn python ENOENT stdErr =

Thank you so much for any help!

edit retag flag offensive close merge delete