问题
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
回答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.
回答2:
In my case, I just updated my jupyter and it worked.
回答3:
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 )
回答4:
Just update the notebook, should work
回答5:
I got this error:
from prompt_toolkit.eventloop import generator_to_async_generator
ImportError: cannot import name 'generator_to_async_generator' from 'prompt_toolkit.eventloop' (/Users/danielmlow/miniconda3/envs/pydra/lib/python3.7/site-packages/prompt_toolkit/eventloop/__init__.py)
So I upgraded prompt_toolkit:
pip install prompt_toolkit==3.0.
回答6:
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
回答7:
I simply just restarted the Anaconda program and opened a new Python 3 notebook, and Jupyter could connect. :)
回答8:
I had the same issue where the kernel would simply not connect. Tried every solution, still no connection.
In the end I noticed some ValueError Exceptions being raised in the console where I started the jupyter client. The source of these exceptions was another python script in the same folder as the notebook.
Fixed the script. Fixed the notebook.
回答9:
I experienced a similar issue on my old PC converted into a Ubuntu 20.04 server, with Jupyterlab running under Jupyterhub. The issue appeared after installing Jupytext with the following command:
python3 -m pip install jupytext --upgrade
which non only installed Jupytext but also upgraded my system to Jupyterlab 2.2.9 and Jupyterhub 1.2.2 (among other packages updates).
After that, running a cell containing the simple code:
3 * 4
under any python 3.6 kernel or even R 3.6 or 4.0 kernel left me with the status message:
Kernel xxx connecting...
but never completing the connection nor the simple computation.
Neither re-installing Tornado to version 5.1.1., nor reinstalling ipywidgets, succeeded in solving the issue.
But finally downgrading Jupyterlab and Jupyterhub to (approximately) the original version numbers worked for me:
python3 -m pip install wheel jupyterhub==1.1.0 jupyterlab==2.1.0 ipywidgets
According to the command outputs, the following packages versions were actually applied:
Installing collected packages: wheel, jupyterhub
Attempting uninstall: wheel
Found existing installation: wheel 0.34.2
Uninstalling wheel-0.34.2:
Successfully uninstalled wheel-0.34.2
Attempting uninstall: jupyterhub
Found existing installation: jupyterhub 1.1.0
Uninstalling jupyterhub-1.1.0:
Successfully uninstalled jupyterhub-1.1.0
Successfully installed jupyterhub-1.2.2 wheel-0.36.1
And after restarting jupyterhub, all my kernels were working again.
回答10:
for linux and windows:
just install ipython kernel
"python3 -m pip install ipykernel"
"python3 -m ipykernel install --user"
then restart jupyter notebook that's it
来源:https://stackoverflow.com/questions/54955563/jupyter-notebook-cannot-connect-to-kernel