简体   繁体   中英

Jupyter Notebook dead Kernel after Anaconda update

I got the following problem. After update Anaconda because I got an error to import skimage.io to a project in Jupyter Notebook an even a greater error appear - Dead Kernel. Right now I could not ever start a project because the Jupyter gives the following error is:

Copy/paste this URL into your browser when you connect for the first time,
to login with a token:
    http://localhost:8888/? 
token=aaf85a5e18489792c87cce65d7a53a0263cd5c08cc7248b 6
[I 00:55:13.451 NotebookApp] Accepting one-time-token-authenticated 
connection from ::1
[I 00:55:31.607 NotebookApp] Kernel started: 608d2190-59e6-4888-b09a- 
e616f67bd5b4
Traceback (most recent call last):
ERROR:tornado.general:Uncaught exception in ZMQStream callback
Traceback (most recent call last):
File "C:\Program Files\Anaconda3\lib\site- 
packages\zmq\eventloop\zmqstream.py", line 432, in _run_callback
callback(*args, **kwargs)
File "C:\Program Files\Anaconda3\lib\site- 
packages\tornado\stack_context.py", line 276, in null_wrapper
return fn(*args, **kwargs)
File "C:\Program Files\Anaconda3\lib\site-packages\ipykernel\kernelbase.py", 
line 283, in dispatcher
return self.dispatch_shell(stream, msg)
File "C:\Program Files\Anaconda3\lib\site-packages\ipykernel\kernelbase.py", 
line 233, in dispatch_shell
self.pre_handler_hook()
File "C:\Program Files\Anaconda3\lib\site-packages\ipykernel\kernelbase.py", 
line 248, in pre_handler_hook
self.saved_sigint_handler = signal(SIGINT, default_int_handler)
File "C:\Program Files\Anaconda3\lib\signal.py", line 47, in signal
handler = _signal.signal(_enum_to_int(signalnum), _enum_to_int(handler))
ValueError: signal only works in main thread  File "C:\Program 
Files\Anaconda3\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)

File "C:\Program Files\Anaconda3\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Program Files\Anaconda3\lib\site-packages\ipykernel_launcher.py", 
line 16, in <module>
app.launch_new_instance()
File "C:\Program Files\Anaconda3\lib\site- 
packages\traitlets\config\application.py", line 658, in launch_instance
app.start()
File "C:\Program Files\Anaconda3\lib\site-packages\ipykernel\kernelapp.py", 
line 477, in start
ioloop.IOLoop.instance().start()
File "C:\Program Files\Anaconda3\lib\site- 
packages\tornado\platform\asyncio.py", line 112, in start
self.asyncio_loop.run_forever()
ERROR:tornado.general:Uncaught exception in zmqstream callback
Traceback (most recent call last):
File "C:\Program Files\Anaconda3\lib\site- 
packages\zmq\eventloop\zmqstream.py", line 450, in _handle_events
self._handle_recv()
File "C:\Program Files\Anaconda3\lib\site- 
packages\zmq\eventloop\zmqstream.py", line 480, in _handle_recv
self._run_callback(callback, msg)
File "C:\Program Files\Anaconda3\lib\site- 
packages\zmq\eventloop\zmqstream.py", line 432, in _run_callback
callback(*args, **kwargs)
File "C:\Program Files\Anaconda3\lib\site- 
packages\tornado\stack_context.py", line 276, in null_wrapper
return fn(*args, **kwargs)
File "C:\Program Files\Anaconda3\lib\site-packages\ipykernel\kernelbase.py", 
line 283, in dispatcher
return self.dispatch_shell(stream, msg)
File "C:\Program Files\Anaconda3\lib\site-packages\ipykernel\kernelbase.py", 
line 233, in dispatch_shell
self.pre_handler_hook()
File "C:\Program Files\Anaconda3\lib\site-packages\ipykernel\kernelbase.py", 
line 248, in pre_handler_hook
self.saved_sigint_handler = signal(SIGINT, default_int_handler)
File "C:\Program Files\Anaconda3\lib\signal.py", line 47, in signal
handler = _signal.signal(_enum_to_int(signalnum), _enum_to_int(handler))
ValueError: signal only works in main thread  File "C:\Program   
Files\Anaconda3\lib\asyncio\base_events.py", line 409, in run_forever

The following packages are required for a brand new installation of jupyter notebook (version 5.6) with conda , so the working version of tornado is 5.1.

ipykernel:          4.8.2-py36_0       conda-forge
ipywidgets:         7.4.0-py_0         conda-forge
jupyter:            1.0.0-py_1         conda-forge
jupyter_client:     5.2.3-py_1         conda-forge
jupyter_console:    5.2.0-py36_0       conda-forge
nbconvert:          5.3.1-py_1         conda-forge
notebook:           5.6.0-py36_0       conda-forge
qtconsole:          4.3.1-py36_0       conda-forge
terminado:          0.8.1-py36_0       conda-forge
tornado:            5.1-py36h470a237_1 conda-forge
widgetsnbextension: 3.4.0-py36_0       conda-forge

To fix this problem, one can manually install the newest version of tornado :

conda install tornado --update

or re-install jupyter notebook from scratch:

conda uninstall jupyter tornado
conda install jupyter

For me, this issue was with ipykernel version mis-match. I had installed google-colab which down-graded my ipykernel . After uninstalling google-colab and upgrading ipykernel to latest the problem got solved.

pip uninstall google-colab

pip install --upgrade ipykernel

升级 ipykernel 对我有用

conda upgrade ipykernel

After trying a lot of "quick fixes" - uninstall and install Jupyter packages and etc., the only way was to uninstall and install Anaconda from the beginning. If you are not afraid to install all the packages from scratch (in my case was not necessary) this solution is the best.

I think the problem here is because of tornado version mismatch. You should just downgrade to older version of tornado to solve the issue. At least, that's what worked for me. This should do the trick.

conda install tornado=4.5.3 

I too faced to problem when l was using my Jupyter lab, l upgraded the version with the command.
pip install jupyterlab —upgrade
To avoid a system wide installation
pip install jupyterlab —upgrade —user

在尝试了各种解决方案后,升级和降级各种依赖项conda upgrade --all对我conda upgrade --all

conda upgrade --all 对我有用

Only

python -m ipykernel install --user

and

python3 -m ipykernel install --user

worked here.

If you are using Jupyter Notebook inside Vscode,

Uninstall all of conda packages

Install Anaconda Clean to remove conda packages

conda install anaconda-clean

This will remove all of your conda packages

anaconda-clean --yes

Then uninstall Jupyter extension in Vscode, close your current jupyter notebook tab, reopen your jupyter notebook file, run it and reinstall jupyter in the pop-up inside Vscode.

This worked for me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM