在Anaconda更新之后,Jupyter Notebook死了内核

时间:2018-04-01 22:12:16

标签: python kernel anaconda jupyter-notebook

我遇到了以下问题。更新Anaconda之后,因为我将一个错误导入skimage.io到Jupyter Notebook中的项目时出现了更大的错误 - 死内核。现在我无法启动项目,因为Jupyter给出了以下错误:

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

8 个答案:

答案 0 :(得分:5)

对于带有conda的jupyter Notebook(版本5.6)的全新安装,需要以下软件包,因此tornado的工作版本为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

要解决此问题,可以手动安装最新版本的tornado

conda install tornado --update

或从头开始重新安装jupyter笔记本:

conda uninstall jupyter tornado
conda install jupyter

答案 1 :(得分:1)

尝试了很多&#34;快速修复&#34; - 卸载并安装Jupyter软件包等,唯一的方法是从头开始卸载和安装Anaconda。如果您不害怕从头开始安装所有软件包(在我的情况下没有必要),这个解决方案是最好的。

答案 2 :(得分:1)

我认为这里的问题是因为龙卷风版本不匹配。您应该降级到旧版龙卷风来解决问题。至少,这对我有用。这应该可以解决问题。

conda install tornado=4.5.3 

答案 3 :(得分:1)

升级ipykernel对我有用

conda upgrade ipykernel

答案 4 :(得分:0)

当我使用Jupyter实验室时,我也面临问题,我使用命令升级了版本。
pip install jupyterlab —upgrade
为避免整个系统的安装
pip install jupyterlab —upgrade —user

答案 5 :(得分:0)

尝试各种解决方案后,升级和降级各种依赖项conda upgrade --all 为我工作。

答案 6 :(得分:0)

conda升级-一切对我有用

答案 7 :(得分:0)

对我来说,此问题与ipykernel版本不匹配有关。我安装了google-colab,降级了ipykernel。卸载google-colab并将ipykernel升级到最新版本后,问题得到解决。

pip uninstall google-colab

pip install --upgrade ipykernel