Jupyter Notebook - Cannot Connect to Kernel
Solution 1
There is a likelihood that you've updated Tornado to 6.0.0 recently. Try reinstalling it to version 5.1.1. It just helped me. Lost 1 hour of precious Saturday time on this.
Solution 2
Create a conda environment using:
conda create -n my_env python=3
Activate the environment using:
source activate my_env
Install the ipykernel using:
conda install ipykernel
ipython kernel install --name my_env --user
Now open the jupyter and select the "my_env" from Kernel option. ( path : jupyter -> kernel -> change kernel -> my_env )
Solution 3
In my case, I just updated my jupyter and it worked.
Solution 4
If the above does not work for you then this is highly recommended.
I had the same issue where the kernel would simply not connect. Tried every solution, still no connection.
In the end I noticed some Value Error Exceptions being raised in the console where I started the notebook client. The source of these exceptions was another python script in the same folder as the notebook.
delete all the python files in the same directory where notebook is installed or move them to some other folder. Fixed the notebook
Solution 5
That worked for me under Python 3.7.
pip3 install tornado==5.1.1
pip3 install notebook==5.7.4

Davis Vickers
Updated on August 12, 2022Comments
-
Davis Vickers 4 months
I've tried installing jupyter notebook using pip3 install jupyter. Every time i launch a new jupyter notebook, the notebook is unable to connect to the kernel. See screenshot below Attaching my requirements.txt file, also i'm on Python version 3.6.8. Jupyter version is 4.4.0 with notebook version 5.7.4.
Where did i go wrong here and how can i fix this? Thanks!
attrs==18.2.0 backcall==0.1.0 bleach==3.1.0 colorama==0.4.1 cycler==0.10.0 decorator==4.3.2 defusedxml==0.5.0 entrypoints==0.3 ipykernel==5.1.0 ipython==7.3.0 ipython-genutils==0.2.0 ipywidgets==7.4.2 jedi==0.13.3 Jinja2==2.10 jsonschema==3.0.1 jupyter==1.0.0 jupyter-client==5.2.4 jupyter-console==6.0.0 jupyter-core==4.4.0 kiwisolver==1.0.1 MarkupSafe==1.1.1 matplotlib==3.0.3 mistune==0.8.4 nbconvert==5.4.1 nbformat==4.4.0 notebook==5.7.4 numpy==1.16.2 pandas==0.24.1 pandocfilters==1.4.2 parso==0.3.4 pickleshare==0.7.5 prometheus-client==0.6.0 prompt-toolkit==2.0.9 Pygments==2.3.1 pyparsing==2.3.1 pyrsistent==0.14.11 python-dateutil==2.8.0 pytz==2018.9 pywinpty==0.5.5 pyzmq==18.0.0 qtconsole==4.4.3 scikit-learn==0.20.3 scipy==1.2.1 seaborn==0.9.0 Send2Trash==1.5.0 six==1.12.0 sklearn==0.0 terminado==0.8.1 testpath==0.4.2 tornado==6.0 traitlets==4.3.2 wcwidth==0.1.7 webencodings==0.5.1 widgetsnbextension==3.4.2
Example
-
Davis Vickers almost 4 yearsThanks, i checked and it looks like Tornado 6.0 came by default when did a pip install jupyter. I was able to uninstall, but i'm not able to do a pip install tornado 5.1.1. Any suggestions? It comes back and says could not find a version that satisfies the requirement 5.1.1.
-
Davis Vickers almost 4 yearsAh, nevermind. I was using wrong syntax. i used pip install tornado==5.1.1 and wala! Now i can connect to jupyter notebook again. Is this a bug on tornado 6.0? Just seems weird that jupyter won't work with tornado 6.0 and it's installed by default.
-
Davis Vickers almost 4 yearsGlad we could all figure it out! Thanks to @Elena for discovering this issue. Just for further documentation, i found this is a common issue many people are reporting recently. github.com/jupyter/jupyter/issues/401
-
Elena Yukhimenko almost 4 years@DavisVickers glad to hear it helped. For me it's not clear if this bug is on tornado or jupyter side. What I know is that the issue appeared as soon as I had updated tornado with the latest version.
-
dhanush-ai1990 almost 3 yearsPlease share more than the code to explain your answer.
-
Florent about 1 yearAfter installing version 5.1.1 I have this error
notebook 6.4.4 requires tornado>=6.1, but you have tornado 5.1.1 which is incompatible
-
Magnus about 1 yearUsing tornado==5.1.1 installed by conda did not solve the issue for me though.
-
Ilona about 1 yearThis solved for me!!! After days of looking for solution.............
-
Ian about 1 yearI had a similar problem. My case is I have a file named 'email.py' in the same folder of my '.ipynb' file. Since 'email' is a standard module, so I need to name my 'email.py' as another name, such as 'play_email.py', as long as the new name is different from any standard module name. The detail please refer to https://groups.google.com/g/jupyter/c/TZwqNstDBRs.
-
Someone_who_likes_SE about 1 yearAs it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
-
vasu 11 monthsThanks a lot! This solution was the one I was looking for
-
András Aszódi 6 monthsI have experienced the same problem with Dockerised JupyterLab. The "old version" (tag=
hub-1.5.0
) works flawlessly. The "newer" versions (tag=hub-2.2.2
orhub-2.3.1
) cannot connect to the kernel. Has nothing to do withtornado
, I am sure.