简体   繁体   English

在jupyter笔记本中,内核立即死亡

[英]In jupyter notebook the kernel dies immediately

I just started jupyter notebook and the the kernel just died, the errors were 我刚启动jupyter笔记本,内核就死了,错误是

   [I 18:14:40.316 NotebookApp] Serving notebooks from local directory: C:\Users\brick
[I 18:14:40.316 NotebookApp] 0 active kernels
[I 18:14:40.316 NotebookApp] The Jupyter Notebook is running at: http://localhost:8888/?token=da23fdd55f08aadd32334cf72b57034f19637b3016b93520
[I 18:14:40.316 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 18:14:40.332 NotebookApp]

    Copy/paste this URL into your browser when you connect for the first time,
    to login with a token:
        http://localhost:8888/?token=da23fdd55f08aadd32334cf72b57034f19637b3016b93520
[I 18:14:41.346 NotebookApp] Accepting one-time-token-authenticated connection from ::1
[I 18:14:50.920 NotebookApp] Creating new notebook in
[I 18:14:54.477 NotebookApp] Kernel started: c867db6f-d2a4-4ddb-9c25-d811e1f2d532
Could not import runpy module
Traceback (most recent call last):
  File "C:\Users\brick\Miniconda3\lib\runpy.py", line 14, in <module>
    import importlib.machinery # importlib first so we can test #15386 via -m
  File "C:\Users\brick\Miniconda3\lib\importlib\__init__.py", line 57, in <module>
    import types
  File "C:\Users\brick\Miniconda3\lib\types.py", line 171, in <module>
    import functools as _functools
  File "C:\Users\brick\Miniconda3\lib\functools.py", line 21, in <module>
    from collections import namedtuple
ImportError: bad magic number in 'collections': b'\x16\r\r\n'
[I 18:14:57.297 NotebookApp] KernelRestarter: restarting kernel (1/5)
Could not import runpy module
Traceback (most recent call last):
  File "C:\Users\brick\Miniconda3\lib\runpy.py", line 14, in <module>
    import importlib.machinery # importlib first so we can test #15386 via -m
  File "C:\Users\brick\Miniconda3\lib\importlib\__init__.py", line 57, in <module>
    import types
  File "C:\Users\brick\Miniconda3\lib\types.py", line 171, in <module>
    import functools as _functools
  File "C:\Users\brick\Miniconda3\lib\functools.py", line 21, in <module>
    from collections import namedtuple
ImportError: bad magic number in 'collections': b'\x16\r\r\n'
[I 18:15:00.340 NotebookApp] KernelRestarter: restarting kernel (2/5)
Could not import runpy module
Traceback (most recent call last):
  File "C:\Users\brick\Miniconda3\lib\runpy.py", line 14, in <module>
    import importlib.machinery # importlib first so we can test #15386 via -m
  File "C:\Users\brick\Miniconda3\lib\importlib\__init__.py", line 57, in <module>
    import types
  File "C:\Users\brick\Miniconda3\lib\types.py", line 171, in <module>
    import functools as _functools
  File "C:\Users\brick\Miniconda3\lib\functools.py", line 21, in <module>
    from collections import namedtuple
ImportError: bad magic number in 'collections': b'\x16\r\r\n'
[I 18:15:03.359 NotebookApp] KernelRestarter: restarting kernel (3/5)
Could not import runpy module
Traceback (most recent call last):
  File "C:\Users\brick\Miniconda3\lib\runpy.py", line 14, in <module>
    import importlib.machinery # importlib first so we can test #15386 via -m
  File "C:\Users\brick\Miniconda3\lib\importlib\__init__.py", line 57, in <module>
    import types
  File "C:\Users\brick\Miniconda3\lib\types.py", line 171, in <module>
    import functools as _functools
  File "C:\Users\brick\Miniconda3\lib\functools.py", line 21, in <module>
    from collections import namedtuple
ImportError: bad magic number in 'collections': b'\x16\r\r\n'
[W 18:15:04.589 NotebookApp] Timeout waiting for kernel_info reply from c867db6f-d2a4-4ddb-9c25-d811e1f2d532
[I 18:15:06.378 NotebookApp] KernelRestarter: restarting kernel (4/5)
WARNING:root:kernel c867db6f-d2a4-4ddb-9c25-d811e1f2d532 restarted
Could not import runpy module
Traceback (most recent call last):
  File "C:\Users\brick\Miniconda3\lib\runpy.py", line 14, in <module>
    import importlib.machinery # importlib first so we can test #15386 via -m
  File "C:\Users\brick\Miniconda3\lib\importlib\__init__.py", line 57, in <module>
    import types
  File "C:\Users\brick\Miniconda3\lib\types.py", line 171, in <module>
    import functools as _functools
  File "C:\Users\brick\Miniconda3\lib\functools.py", line 21, in <module>
    from collections import namedtuple
ImportError: bad magic number in 'collections': b'\x16\r\r\n'
[W 18:15:09.406 NotebookApp] KernelRestarter: restart failed
[W 18:15:09.406 NotebookApp] Kernel c867db6f-d2a4-4ddb-9c25-d811e1f2d532 died, removing from map.
ERROR:root:kernel c867db6f-d2a4-4ddb-9c25-d811e1f2d532 restarted failed!
[W 18:15:09.468 NotebookApp] Kernel deleted before session
[W 18:15:09.472 NotebookApp] 410 DELETE /api/sessions/4c861646-dd4c-45f9-9863-7ec1f4dec185 (::1) 7.99ms referer=http://localhost:8888/notebooks/Untitled4.ipynb?kernel_name=python3
[I 18:16:54.961 NotebookApp] Saving file at /Untitled4.ipynb
[I 21:29:10.617 NotebookApp] Kernel started: 64d63304-b152-4869-8cff-92612086b891
Could not import runpy module
Traceback (most recent call last):
  File "C:\Users\brick\Miniconda3\lib\runpy.py", line 14, in <module>
    import importlib.machinery # importlib first so we can test #15386 via -m
  File "C:\Users\brick\Miniconda3\lib\importlib\__init__.py", line 57, in <module>
    import types
  File "C:\Users\brick\Miniconda3\lib\types.py", line 171, in <module>
    import functools as _functools
  File "C:\Users\brick\Miniconda3\lib\functools.py", line 21, in <module>
    from collections import namedtuple
ImportError: bad magic number in 'collections': b'\x16\r\r\n'
[I 21:29:13.230 NotebookApp] KernelRestarter: restarting kernel (1/5)
Could not import runpy module
Traceback (most recent call last):
  File "C:\Users\brick\Miniconda3\lib\runpy.py", line 14, in <module>
    import importlib.machinery # importlib first so we can test #15386 via -m
  File "C:\Users\brick\Miniconda3\lib\importlib\__init__.py", line 57, in <module>
    import types
  File "C:\Users\brick\Miniconda3\lib\types.py", line 171, in <module>
    import functools as _functools
  File "C:\Users\brick\Miniconda3\lib\functools.py", line 21, in <module>
    from collections import namedtuple
ImportError: bad magic number in 'collections': b'\x16\r\r\n'
[I 21:29:16.263 NotebookApp] KernelRestarter: restarting kernel (2/5)
Could not import runpy module
Traceback (most recent call last):
  File "C:\Users\brick\Miniconda3\lib\runpy.py", line 14, in <module>
    import importlib.machinery # importlib first so we can test #15386 via -m
  File "C:\Users\brick\Miniconda3\lib\importlib\__init__.py", line 57, in <module>
    import types
  File "C:\Users\brick\Miniconda3\lib\types.py", line 171, in <module>
    import functools as _functools
  File "C:\Users\brick\Miniconda3\lib\functools.py", line 21, in <module>
    from collections import namedtuple
ImportError: bad magic number in 'collections': b'\x16\r\r\n'
[I 21:29:19.295 NotebookApp] KernelRestarter: restarting kernel (3/5)
Could not import runpy module
Traceback (most recent call last):
  File "C:\Users\brick\Miniconda3\lib\runpy.py", line 14, in <module>
    import importlib.machinery # importlib first so we can test #15386 via -m
  File "C:\Users\brick\Miniconda3\lib\importlib\__init__.py", line 57, in <module>
    import types
  File "C:\Users\brick\Miniconda3\lib\types.py", line 171, in <module>
    import functools as _functools
  File "C:\Users\brick\Miniconda3\lib\functools.py", line 21, in <module>
    from collections import namedtuple
ImportError: bad magic number in 'collections': b'\x16\r\r\n'
[W 21:29:21.159 NotebookApp] Timeout waiting for kernel_info reply from 64d63304-b152-4869-8cff-92612086b891
[I 21:29:22.312 NotebookApp] KernelRestarter: restarting kernel (4/5)
WARNING:root:kernel 64d63304-b152-4869-8cff-92612086b891 restarted
[E 21:29:22.317 NotebookApp] KernelRestarter: restart callback <bound method ZMQChannelsHandler.on_kernel_restarted of ZMQChannelsHandler(64d63304-b152-4869-8cff-92612086b891)> failed
    Traceback (most recent call last):
      File "C:\Users\brick\Miniconda3\lib\site-packages\jupyter_client\restarter.py", line 81, in _fire_callbacks
        callback()
      File "C:\Users\brick\Miniconda3\lib\site-packages\notebook\services\kernels\handlers.py", line 435, in on_kernel_restarted
        self._send_status_message('restarting')
      File "C:\Users\brick\Miniconda3\lib\site-packages\notebook\services\kernels\handlers.py", line 431, in _send_status_message
        self.write_message(json.dumps(msg, default=date_default))
      File "C:\Users\brick\Miniconda3\lib\site-packages\tornado\websocket.py", line 249, in write_message
        raise WebSocketClosedError()
    tornado.websocket.WebSocketClosedError
Could not import runpy module
Traceback (most recent call last):
  File "C:\Users\brick\Miniconda3\lib\runpy.py", line 14, in <module>
    import importlib.machinery # importlib first so we can test #15386 via -m
  File "C:\Users\brick\Miniconda3\lib\importlib\__init__.py", line 57, in <module>
    import types
  File "C:\Users\brick\Miniconda3\lib\types.py", line 171, in <module>
    import functools as _functools
  File "C:\Users\brick\Miniconda3\lib\functools.py", line 21, in <module>
    from collections import namedtuple
ImportError: bad magic number in 'collections': b'\x16\r\r\n'
[W 21:29:25.552 NotebookApp] KernelRestarter: restart failed
[W 21:29:25.552 NotebookApp] Kernel 64d63304-b152-4869-8cff-92612086b891 died, removing from map.
ERROR:root:kernel 64d63304-b152-4869-8cff-92612086b891 restarted failed!
[E 21:29:25.567 NotebookApp] KernelRestarter: dead callback <bound method ZMQChannelsHandler.on_restart_failed of ZMQChannelsHandler(64d63304-b152-4869-8cff-92612086b891)> failed
    Traceback (most recent call last):
      File "C:\Users\brick\Miniconda3\lib\site-packages\jupyter_client\restarter.py", line 81, in _fire_callbacks
        callback()
      File "C:\Users\brick\Miniconda3\lib\site-packages\notebook\services\kernels\handlers.py", line 439, in on_restart_failed
        self._send_status_message('dead')
      File "C:\Users\brick\Miniconda3\lib\site-packages\notebook\services\kernels\handlers.py", line 431, in _send_status_message
        self.write_message(json.dumps(msg, default=date_default))
      File "C:\Users\brick\Miniconda3\lib\site-packages\tornado\websocket.py", line 249, in write_message
        raise WebSocketClosedError()
    tornado.websocket.WebSocketClosedError
[I 23:11:45.347 NotebookApp] Interrupted...
[I 23:11:45.394 NotebookApp] Shutting down kernels

I am using python 3.6.1, and used Miniconda3 to acquire jupyter notebook please help me the kernel also failed to restart. 我正在使用python 3.6.1,并使用Miniconda3来获取jupyter笔记本,请帮助我,内核也无法重启。 Thanks! 谢谢!

I hope this will finally help me 希望这对我有帮助

The "bad magic number" b'\\x16\\r\\r\\n' is used in .pyc files up to Python 3.5.2. 在python 3.5.2之前的.pyc文件中使用了“错误的魔术数字” b'\\x16\\r\\r\\n' Python broke the world when the magic number got updated to \\x17 recently. 最近魔术数更新为\\x17时,Python 打破了世界 This may be unrelated to your problem, but my guess is that your interpreter is >= 3.5.3 and your IPython kernel is <= 3.5.2, trying to use the same module-path. 这可能与您的问题无关,但是我猜测您的解释器> = 3.5.3,而IPython内核是<= 3.5.2,试图使用相同的模块路径。

The cause of this error are .pyc files, cached python modules "compiled" by a previous version of Python on your computer, that the interpreter IPython is now using can't unpickle. 导致此错误的原因是.pyc文件,由计算机上的早期版本的Python“编译”的缓存的python模块,IPython现在使用的解释器无法释放。

The solution is to re-install everything, that is, getting a matching interpreter and IPython. 解决方案是重新安装所有内容,即获取匹配的解释器和IPython。 You might get away with simply deleting all .pyc files; 您可能只需删除所有.pyc文件就可以摆脱; they are regenerated automatically. 它们会自动重新生成。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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