当前位置: 代码迷 >> 综合 >> jupyter notebook 报错的坑【The kernel has died, and the automatic restart has failed.】
  详细解决方案

jupyter notebook 报错的坑【The kernel has died, and the automatic restart has failed.】

热度:4   发布时间:2024-01-11 00:57:55.0

问题点
打开jupyter notebook遇到的问题表现:
dead Kernel
遇到这个问题,首先需要分析报错信息,不要听信网上一面之词,对解决方法无益处。

[I 11:49:06.081 NotebookApp] KernelRestarter: restarting kernel (4/5), new random ports
kernel a67705c9-a10f-4e18-9190-03e253b686fd restarted
Traceback (most recent call last):File "D:\install\HaoZip\py3\lib\runpy.py", line 193, in _run_module_as_main"__main__", mod_spec)File "D:\install\HaoZip\py3\lib\runpy.py", line 85, in _run_codeexec(code, run_globals)File "D:\install\HaoZip\py3\lib\site-packages\ipykernel_launcher.py", line 15, in <module>from ipykernel import kernelapp as appFile "D:\install\HaoZip\py3\lib\site-packages\ipykernel\__init__.py", line 2, in <module>from .connect import *File "D:\install\HaoZip\py3\lib\site-packages\ipykernel\connect.py", line 13, in <module>from IPython.core.profiledir import ProfileDirFile "D:\install\HaoZip\py3\lib\site-packages\IPython\__init__.py", line 55, in <module>from .terminal.embed import embedFile "D:\install\HaoZip\py3\lib\site-packages\IPython\terminal\embed.py", line 16, in <module>from IPython.terminal.interactiveshell import TerminalInteractiveShellFile "D:\install\HaoZip\py3\lib\site-packages\IPython\terminal\interactiveshell.py", line 20, in <module>from prompt_toolkit.formatted_text import PygmentsTokens
ModuleNotFoundError: No module named 'prompt_toolkit.formatted_text'

问题找到了,接下来对症下药,为什么出现这种情况,首先排除版本的问题
运行如下代码:

 pip install --upgrade notebookpip install --upgrade jupyter

结果并没有解决这个问题,继续思考,是不是由于版本的问题,这个时候搜索的问题就有了明确的目的性。最终 的确是由于版本的问题,输入如下代码:

pip3 install --upgrade prompt-toolkit==2.0.4

升级版本之后的,就能正常运行了

 

  相关解决方案