271

How can I remove a kernel from jupyter notebook?

I have R kernel on my jupyter notebook. Recently kernel always dies right after I open a new notebook.

8 Answers 8

496

Run jupyter kernelspec list to get the paths of all your kernels.
Then simply uninstall your unwanted-kernel

jupyter kernelspec uninstall unwanted-kernel

Old answer
Delete the folder corresponding to the kernel you want to remove.

The docs has a list of the common paths for kernels to be stored in: http://jupyter-client.readthedocs.io/en/latest/kernels.html#kernelspecs

4
  • 5
    Maybe obvious comment: You have to activate the virtualenv in which you installed jupyter before you can run the command. Aug 30, 2018 at 8:54
  • 23
    jupyter kernelspec remove <kernel_name> now exists see my answer below stackoverflow.com/a/52606602/4413446
    – Romain
    Oct 2, 2018 at 10:33
  • 1
    Yes, if the kernel is deleted manually then that is effectively the same as uninstalling it Aug 12, 2019 at 10:02
  • 1
    What if this leaves some traces? When I install a kernel with the same name after this, the kernel does not work properly.
    – Soerendip
    May 18, 2021 at 4:17
74

jupyter kernelspec remove now exists, see #7934. So you can just.

# List all kernels and grap the name of the kernel you want to remove
jupyter kernelspec list
# Remove it
jupyter kernelspec remove <kernel_name>

That's it.

3
  • 5
    Yeah, uninstall is simply an alias of remove these days...
    – Kris Stern
    Feb 3, 2020 at 12:23
  • 2
    This is a more complete answer, the first command allows you to check all the venvs linked to the jupyter notebooks. Jan 2 at 13:16
  • 1
    Thanks for the list command! Very helpful
    – Doracahl
    Apr 12 at 17:53
73

You can delete it in the terminal via:

jupyter kernelspec uninstall yourKernel

where yourKernel is the name of the kernel you want to delete.

3
  • 3
    sudo may not even be necessary. This is a much better answer than the accepted one.
    – mbauman
    Sep 7, 2018 at 15:20
  • I did it today without sudo. And definitely this is the cleanest way. This should be the accepted answer. Jan 15 at 21:03
  • The accepted answer was updated at some point with my content, so that the user can keep collecting upvotes... :D
    – dopexxx
    Jan 16 at 10:55
25

There two ways, what I found either go to the directory where kernels are residing and delete from there. Secondly, using this command below

List all kernels and grap the name of the kernel you want to remove

 jupyter kernelspec list 

to get the paths of all your kernels.

Then simply uninstall your unwanted-kernel

jupyter kernelspec remove kernel_name
15

Just for completeness, you can get a list of kernels with jupyter kernelspec list, but I ran into a case where one of the kernels did not show up in this list. You can find all kernel names by opening a Jupyter notebook and selecting Kernel -> Change kernel. If you do not see everything in this list when you run jupyter kernelspec list, try looking in common Jupyter folders:

ls ~/.local/share/jupyter/kernels  # usually where local kernels go
ls /usr/local/share/jupyter/kernels  # usually where system-wide kernels go
ls /usr/share/jupyter/kernels  # also where system-wide kernels can go

Also, you can delete a kernel with jupyter kernelspec remove or jupyter kernelspec uninstall. The latter is an alias for remove. From the in-line help text for the command:

uninstall
    Alias for remove
remove
    Remove one or more Jupyter kernelspecs by name.
0

In jupyter notebook run:

!echo y | jupyter kernelspec uninstall unwanted-kernel 

In anaconda prompt run:

jupyter kernelspec uninstall unwanted-kernel
0

If you are doing this for virtualenv, the kernels in inactive environments might not be shown with jupyter kernelspec list, as suggested above. You can delete it from directory:

~/.local/share/jupyter/kernels/
0

For Example: To reverse the command python -m ipykernel install --user --name tensorflow --display-name "Python 3.6 (tensorflow)", you need to uninstall the IPython kernel with the same name and display name.

You can do this by running the following command:

jupyter kernelspec uninstall tensorflow

This will remove the IPython kernel with the name "tensorflow" and the display name "Python 3.6 (tensorflow)" from your system.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.