jupyter_client: Cannot remove "native" Python 2 kernel
When you look at the help for jupyter kernelspec remove
(jupyter kernelspec remove -h
), it gives you this example command:
jupyter kernelspec remove python2
So this leads me to believe you can delete the python2
kernel, but in fact, if I try to, it tells me the kernel doesn’t exist:
[Anaconda2] C:\Users\ristew\PycharmProjects\ipywktest>jupyter kernelspec remove python2
Couldn't find kernel spec(s): python2
This is in spite of the fact that the python2
kernel is clearly installed:
[Anaconda2] C:\Users\ristew\PycharmProjects\ipywktest>jupyter kernelspec list
Available kernels:
python2 C:\Users\ristew\AppData\Local\Continuum\Anaconda2\lib\site-packages\ipykernel\resources
ipywktest C:\ProgramData\jupyter\kernels\ipywktest
pysparkkernel C:\ProgramData\jupyter\kernels\pysparkkernel
sparkkernel C:\ProgramData\jupyter\kernels\sparkkernel
I had a look at the code and it seems like this is happening because of this line in jupyter_client.kernelspecapp.RemoveKernelSpec
:
self.kernel_spec_manager.ensure_native_kernel = False
This line has the effect of “ignoring” the native kernel, as we see in jupyter_client.kernelspec.KernelSpecManager
:
if self.ensure_native_kernel and NATIVE_KERNEL_NAME not in d:
try:
from ipykernel.kernelspec import RESOURCES
self.log.debug("Native kernel (%s) available from %s",
NATIVE_KERNEL_NAME, RESOURCES)
d[NATIVE_KERNEL_NAME] = RESOURCES
So it’s impossible to delete the python2 kernel. I’ve tried this on both my Windows machine and a Linux machine, to no avail.
A couple questions:
- Is it possible to work around this by e.g. deleting the folder where the kernel is located?
- Is this the intended behavior or is it a bug? If it’s the intended behavior, can the documentation be updated to reflect this?
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 16 (7 by maintainers)
This might:
@dsblank Thanks a lot! This works!