20

In Visual Studio Code, when I start the Python Interactive Window (by calling "Run Selection/Line in Python Interactive Window" command, for example), Jupyter server starts in the background. In that window, I can restart the kernel, but I can not find a way to stop the server. How can it be stopped? Simply closing the interactive window only disconnects from the server, but does not stop it.

5 Answers 5

19

There is no extra function build in VSCode. But you can manage it regularly from the terminal. You can stop it using jupyter-notebook stop.

Other ways are mentioned here as well: How to close IPython Notebook properly?

Sign up to request clarification or add additional context in comments.

1 Comment

getting "ConnectionRefusedError" and notebook keeps running... also how do i stop a specific notebook / kernel VScode only allows restart... which is okay, but not quite what i want in some cases.
5

I have just started running notebooks in VSCode (Python) and wanted to stop a running cell, but couldn't find any way.

Just out of desperation I tried to change the running cell into a markdown cell and back to a code cell. That seemed to halt the process despite being hilariously inelegant.

3 Comments

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
"hilariously inelegant." That's now going to be the principle I strive towards! But joking aside: This did seem to solve a similar issue for me, where I could "recover" a cell that somehow disconnected from the Kernel ( Failed to interrupt the Kernel. No kernel associated with the notebook. View Jupyter log for further details.) But it's not really consistent and I don't have a clue what it does exactly. So yea, hilariously inelegant.
This also worked inside a cloud server running docker which has VSCode running a Jupyter Lab Notebook. Inelegant, yes, but worked.
2

Finding the process in the task manager was the only option that worked for me.

If you are using the "Default" VSCode jupyter option running jupyter-notebook stop won't work. This is a known bug in vscode, but they closed the issue.

Comments

1

Be aware that

  • Jupyter Lab
  • Jupyter Notebook

and the kernel that they (they are 'servers') give you to run each Notebook are different things.


To stop a running Jupyter Notebook / Lab server, you can use the following command:

jupyter notebook stop
jupyter lab stop

This command will stop the Jupyter notebook server running on the default port (8888).

If your server is running on a different port, you need to specify it:

jupyter notebook stop {port_number}
jupyter lab stop {port_number}

Stopping the server will stop all the running kernels.


Unfortunately, there's no built-in command line interface for listing running Jupyter kernels or stopping a specific kernel. You can only do this through the Jupyter notebook or Jupyter Lab interface.

When you hover over a kernel, an x will appear for you to close it manually. [Image is JupyterLab]

enter image description here

Comments

-1

I found this recommendation online for Jupyter PowerToys extension. It contains the Active Jupyter Sessions feature to shut down individual notebooks. enter image description here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.