It appears that somehow one of my kernels is deleted. And perhaps that\'s why I am getting this error. How could I possibly fix it? Can I reinstall something (the kernel in the
Solved the problem by editing the relevant
kernelspec
:kernel.json
file after fresh installation of Anaconda.
As reported earlier, I found that I had two kernelspecs
. (command: jupyter kernelspec list
)
C:\Users\raysu\AppData\Roaming\jupyter\kernels\python3
C:\ProgramData\jupyter\kernels\vpython
The kernelspec
is a .json
file that maintains kernel-specifications for jupyter-notebook/lab to launch a certain kernel. Fortunately, the kernel vpython
was functioning and that helped me narrow down the source of the problem located inside kernelpsec: python3
. I had to correct the path to the python executable (python.exe
) and that solved the issue.
I would like to mention that in this case the following two resources came handy. I got more clarity in where the problem could be, after I saw the typical-structure of the kernelspec
document.
Note: However, since I cannot test this theory, I would ask anyone else in a similar problem, to first make a copy of the old kernel.json
file and then update the path to python.exe
file. If that resolves the kernel error, then reinstalling Anaconda altogether may not be necessary.
Long story short:
If your jupyter notebook/lab environment shows you kernel error, most likely the source of the problem is inside the kernelspec file: kernel.json
and the path to python.exe
is incorrect. This could be a more likely scenario, if the same kernel error
persists even after fresh re-installation of anaconda/jupyter-notebook/lab.
For instance, in my case, the python3-kernelspec
was located at:
"C:\Users\raysu\AppData\Roaming\jupyter\kernels\python3"
And the python.exe
was located at:
"C:\Users\raysu\Anaconda3\python.exe"
However, the path to the python-executable was wrong: it was still showing the path from the old installation. And post-anaconda-reinstallation, this path had changed. So, I had to update the kernelspec for python3 by editing kernel.json
file.
# kernel.json file
{
"argv": [
"C:\\Users\\raysu\\Anaconda3\\python.exe",
"-m",
"ipykernel_launcher",
"-f",
"{connection_file}"
],
"display_name": "Python 3",
"language": "python"
}
If this does not solve your problem, please consult the following two documents. I wasted 4 days because of this. Hopefully, this answer would help out someone in future.
I was able to resolve the problem here
I installed jupyter_client 5.3.4 and jupyter_core 4.6.0 with this command
pip install jupyter_client --upgrade