microsoft / vscode-jupyter

VS Code Jupyter extension
https://marketplace.visualstudio.com/items?itemName=ms-toolsai.jupyter
MIT License
1.25k stars 275 forks source link

VSCode suddenly unable to find or start python jupyter kernels #15783

Closed zacps closed 22 hours ago

zacps commented 2 weeks ago

Applies To

What happened?

Created a new notebook, and attempted to select a kernel and run a cell.

The kernel picker shows no options under Python environments, and running a cell shows:

Failed to start the Kernel. 
View Jupyter [log](command:jupyter.viewOutput) for further details.

This broke suddenly, without any obvious changes on my part (as far as I know).

VS Code Version

Version: 1.90.2 Commit: 5437499feb04f7a586f677b155b039bc2b3669eb Date: 2024-06-18T22:33:48.698Z Electron: 29.4.0 ElectronBuildId: 9728852 Chromium: 122.0.6261.156 Node.js: 20.9.0 V8: 12.2.281.27-electron.0 OS: Linux x64 6.5.0-41-generic snap

Jupyter Extension Version

v2024.5.0

Jupyter logs

Visual Studio Code (1.90.2, undefined, desktop)
Jupyter Extension Version: 2024.5.0.
Python Extension not installed.
Pylance Extension not installed.
Platform: linux (x64).
Workspace folder ~/REPO_OBSCURED, Home = /home/zac
08:51:50.996 [info] Starting Kernel (Python 3 (ipykernel)) for '~/REPO_OBSCURED/ran_notebooks/testing.ipynb' (disableUI=false)
08:51:51.008 [info] Launching Raw Kernel Python 3 (ipykernel) # python
08:51:51.016 [info] Process Execution: /python -m ipykernel_launcher --f=/home/~/.local/share/jupyter/runtime/kernel-v2-2311178cDwjhvlbJF.json
    > cwd: //home/~/REPO_OBSCURED/ran_notebooks
08:51:51.019 [error] Kernel died Error: spawn python ENOENT
    at Process.ChildProcess._handle.onexit (node:internal/child_process:286:19)
    at onErrorNT (node:internal/child_process:484:16)
    at processTicksAndRejections (node:internal/process/task_queues:82:21) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'spawn python',
  path: 'python',
  spawnargs: [
    '-m',
    'ipykernel_launcher',
    '--f=/home/~/.local/share/jupyter/runtime/kernel-v2-2311178cDwjhvlbJF.json'
  ]
} 
08:51:51.021 [error] Disposing kernel process due to an error Error: spawn python ENOENT
    at Process.ChildProcess._handle.onexit (node:internal/child_process:286:19)
    at onErrorNT (node:internal/child_process:484:16)
    at processTicksAndRejections (node:internal/process/task_queues:82:21) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'spawn python',
  path: 'python',
  spawnargs: [
    '-m',
    'ipykernel_launcher',
    '--f=/home/~/.local/share/jupyter/runtime/kernel-v2-2311178cDwjhvlbJF.json'
  ]
}
08:51:51.021 [error] 
08:51:51.029 [error] Failed to connect raw kernel session: Error: The kernel died. Error: ... View Jupyter [log](command:jupyter.viewOutput) for further details.
08:51:51.029 [error] Failed to connect raw kernel session: Error: The kernel died. Error: ... View Jupyter [log](command:jupyter.viewOutput) for further details.
08:51:51.029 [warn] Failed to shutdown kernel, .python3./python./.-m#ipykernel_launcher TypeError: Cannot read properties of undefined (reading 'dispose')
    at DT.shutdown (/home/~/.vscode/extensions/ms-toolsai.jupyter-2024.5.0-linux-x64/dist/extension.node.js:314:13629)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at _T.shutdown (/home/~/.vscode/extensions/ms-toolsai.jupyter-2024.5.0-linux-x64/dist/extension.node.js:314:22107)
08:51:51.031 [warn] Error occurred while trying to start the kernel, options.disableUI=false Error: The kernel died. Error: ... View Jupyter [log](command:jupyter.viewOutput) for further details.
    > Kernel Id = .python3./python./.-m#ipykernel_launcher
    > at new r (/home/~/.vscode/extensions/ms-toolsai.jupyter-2024.5.0-linux-x64/dist/extension.node.js:108:4480)
    > originalException = Error: spawn python ENOENT
    > stdErr = 
08:51:51.031 [warn] Kernel Error, context = start Error: The kernel died. Error: ... View Jupyter [log](command:jupyter.viewOutput) for further details.
    > Kernel Id = .python3./python./.-m#ipykernel_launcher
    > at new r (/home/~/.vscode/extensions/ms-toolsai.jupyter-2024.5.0-linux-x64/dist/extension.node.js:108:4480)
    > originalException = Error: spawn python ENOENT
    > stdErr = 
08:51:51.037 [info] Dispose Kernel '~/REPO_OBSCURED/ran_notebooks/testing.ipynb' associated with '~/REPO_OBSCURED/ran_notebooks/testing.ipynb'
08:51:51.038 [error] Error in execution Error: The kernel died. Error: ... View Jupyter [log](command:jupyter.viewOutput) for further details.
    > Kernel Id = .python3./python./.-m#ipykernel_launcher
    > at new r (/home/~/.vscode/extensions/ms-toolsai.jupyter-2024.5.0-linux-x64/dist/extension.node.js:108:4480)
    > originalException = Error: spawn python ENOENT
    > stdErr = 
08:51:51.038 [error] Error in execution (get message for cell) Error: The kernel died. Error: ... View Jupyter [log](command:jupyter.viewOutput) for further details.
    > Kernel Id = .python3./python./.-m#ipykernel_launcher
    > at new r (/home/~/.vscode/extensions/ms-toolsai.jupyter-2024.5.0-linux-x64/dist/extension.node.js:108:4480)
    > originalException = Error: spawn python ENOENT
    > stdErr = 
08:52:57.614 [error] Failed to install Python Extension via Kernel Picker command
08:52:57.615 [warn] DataScience Error Error: Failed to install the Python Extension.
    at ab.installPythonExtensionViaKernelPicker (/home/~/.vscode/extensions/ms-toolsai.jupyter-2024.5.0-linux-x64/dist/extension.node.js:314:34577)
    at h (/snap/code/162/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:153:200468)
08:53:40.742 [error] Failed to install Python Extension via Kernel Picker command
08:53:40.743 [warn] DataScience Error Error: Failed to install the Python Extension.
    at ab.installPythonExtensionViaKernelPicker (/home/~/.vscode/extensions/ms-toolsai.jupyter-2024.5.0-linux-x64/dist/extension.node.js:314:34577)
    at h (/snap/code/162/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:153:200468)

Coding Language and Runtime Version

Python 3.10.12

Language Extension Version (if applicable)

v2024.8.1

Anaconda Version (if applicable)

No response

Running Jupyter locally or remotely?

Local

hnry-m commented 1 week ago

+1 to this. Facing same issue but on a remotely running Jupyter.

DonJayamanne commented 1 week ago

@hnry-m When you say remotely running Jupyter, are you connecting to a Jupyter server (not VS Code) thats running on a different machine? If thats the case, please file a separate issue, this is not an issue with remote and unlikely to be related.

DonJayamanne commented 1 week ago

@zacps Thank you for filing this issue. It looks like you have selected a Jupyter kernel, however the kernel points to python instead of pointing to the fully qualified path to the python exe.

Suggestions, please can you select a Python Environment instead of selecting the Jupyter Kernel and try that. The reason this would happen is if you have Python installed in some non-global location or the like and Python is not in your current PATH.

DonJayamanne commented 1 week ago

This broke suddenly, without any obvious changes on my part (as far as I know).

Most likely cause is python is no longer in your PATH (env variable) Or you have selected Jupyter Kernel instead of selecting a Python Environment.

zacps commented 1 week ago

@DonJayamanne python is, and always has been, available in PATH. I realised after posting this issue it occurs only in one folder (implicit workspace).

There are no settings configured differently as far as I know, except for these:

{
  "python.testing.pytestArgs": [
    "tests"
  ],
  "python.testing.pytestEnabled": true,
  "python.testing.unittestEnabled": false
}

which shouldn't make any difference and change nothing if removed.

The environment I want to use is a local virtual environment., but none other than one old explicitly registered kernel work.

I imagine the problem is due to the broken path /home/~/.vscode/extensions/ms-toolsai.jupyter-2024.5.0-linux-x64/dist/... referred to in the logs.

baseline0 commented 1 week ago

+1 to issue. encountered while using jupyter-server and remote-ssh extension for vscode.

DonJayamanne commented 1 week ago

@baseline0 @zacps Please could you enable logging as follows:

DonJayamanne commented 1 week ago

This message indicates that python is not in PATH I'd like the logs to see what Python is used.

08:51:51.019 [error] Kernel died Error: spawn python ENOENT
    at Process.ChildProcess._handle.onexit (node:internal/child_process:286:19)
    at onErrorNT (node:internal/child_process:484:16)
    at processTicksAndRejections (node:internal/process/task_queues:82:21) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'spawn python',
  path: 'python',
  spawnargs: [
    '-m',
    'ipykernel_launcher',
    '--f=/home/~/.local/share/jupyter/runtime/kernel-v2-2311178cDwjhvlbJF.json'
  ]
VSCodeTriageBot commented 22 hours ago

This issue has been closed automatically because it needs more information and has not had recent activity. See also our issue reporting guidelines.

Happy Coding!