Unable to start Jupyter Notebook Kernel in VS Code
Asked Answered
V

6

6

I am trying to run a Jupyter Notebook in VS Code. However, I'm getting the following error message whenever I try to execute a cell:

Failed to start the Kernel. 
Jupyter server crashed. Unable to connect. 
Error code from Jupyter: 1
usage: jupyter.py [-h] [--version] [--config-dir] [--data-dir] [--runtime-dir]
                  [--paths] [--json] [--debug]
                  [subcommand]

Jupyter: Interactive Computing

positional arguments:
  subcommand     the subcommand to launch

options:
  -h, --help     show this help message and exit
  --version      show the versions of core jupyter packages and exit
  --config-dir   show Jupyter config dir
  --data-dir     show Jupyter data dir
  --runtime-dir  show Jupyter runtime dir
  --paths        show all Jupyter paths. Add --json for machine-readable
                 format.
  --json         output paths as machine-readable json
  --debug        output debug information about paths

Available subcommands:

Jupyter command `jupyter-notebook` not found. 
View Jupyter log for further details.

The Jupyter log referred to by the diagnostic message just contains the same text as the above diagnostic message repeated multiple times.

I believe this post refers to the same issue. Unfortunately, the accepted answer does not work for me because I do not have Python: Select Interpreter to Start Jupyter server in my Command Palette.

The file was working normally this morning. I also tried uninstalling and reinstalling the extensions.

How can I get the Kernel to start?

Virulence answered 2/2, 2023 at 23:35 Comment(0)
A
12

This sounds like it might be a bug that found in the 2023.1 version of the Jupyter extension that affects MacOS users: Starting a Jupyter server kernel fails (when zmq does not work) #12714 (duplicates: Failed to start the Kernel, version v2023.1.2000312134 #12726, Jupyter server crashed. Unable to connect. #12746) The solution recommended there was to switch to the pre-release version while waiting for the fix to come to the regular-release-channel released the fix. Others in the threads there also found that rolling back to older extension versions also worked for them (you can rollback clicking into the down menu button next to the extension's uninstall button).

If none of those solutions work, try this:

pip install --upgrade --force-reinstall --no-cache-dir jupyter

And then restart VS Code. If you already have it open, you can do this in the VS Code command palette with the Developer: Reload Window command.

Credit: The above command is based on this answer by @Spandana-r to the question After installing with pip, "jupyter: command not found".

Antitrust answered 3/2, 2023 at 22:12 Comment(1)
I have the exact same issue and this does not resolve for me. I have created a post.Phox
H
1

Close the vscode then uninstall jupyter and notebook one after another.

  1. pip uninstall jupyter
  2. pip uninstall notebook

Now, open vs code and run cell like. print ("Hello") Vscode will ask you to download jupyter. Allow it. Now It is ready to work.

Hebner answered 5/2, 2023 at 4:28 Comment(0)
P
0

Did you work in a python environment with jupyter installed?

I think the problem is that you chose a kernel that does not have jupyter installed, which leads to failure.

You can click the button on the top right to choose the kernel.

enter image description here

Pavier answered 3/2, 2023 at 1:25 Comment(0)
B
0

I followed this suggestion and downgraded my VSCode to the previous version.

https://mcmap.net/q/1770177/-after-the-latest-update-of-vscode-i-can-39-t-run-jupyter-notebooks-anymore

The previous version worked fine but upgrading to the newest version brought back the issue.

Bunkum answered 10/2, 2023 at 18:38 Comment(0)
T
0

try to use python.exe -m notebook

Tunable answered 30/8, 2023 at 9:4 Comment(0)
G
0

Go into VS Code > Extension > Uninstall dropdown > Install Another Version, chose the 2023.4 option, downloaded the VSIX, and installed it. Now the issue is resolved!

Reference : https://github.com/microsoft/vscode-jupyter/issues/13699#issuecomment-1591557273

Gonagle answered 12/6 at 8:57 Comment(1)

© 2022 - 2024 — McMap. All rights reserved.