解决anaconda3.6安装jupyter notebook 报错的坑【The kernel has died, and the automatic restart has failed.】

解决anaconda3.6安装 jupyter notebook

  1. 安装相应的包
    安装anaconda3.6
    windows+R,键入“cmd”,进入windows命令行模式,输入:jupyter notebook
    这一部分可以自行百度
  2. 遇到的问题

问题点
打开jupyter notebook遇到的问题表现:
解决anaconda3.6安装jupyter notebook 报错的坑【The kernel has died, and the automatic restart has failed.】_第1张图片
遇到这个问题,首先需要分析报错信息,不要听信网上一面之词,对解决方法无益处。

[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_code
    exec(code, run_globals)
  File "D:\install\HaoZip\py3\lib\site-packages\ipykernel_launcher.py", line 15, in 
    from ipykernel import kernelapp as app
  File "D:\install\HaoZip\py3\lib\site-packages\ipykernel\__init__.py", line 2, in 
    from .connect import *
  File "D:\install\HaoZip\py3\lib\site-packages\ipykernel\connect.py", line 13, in 
    from IPython.core.profiledir import ProfileDir
  File "D:\install\HaoZip\py3\lib\site-packages\IPython\__init__.py", line 55, in 
    from .terminal.embed import embed
  File "D:\install\HaoZip\py3\lib\site-packages\IPython\terminal\embed.py", line 16, in 
    from IPython.terminal.interactiveshell import TerminalInteractiveShell
  File "D:\install\HaoZip\py3\lib\site-packages\IPython\terminal\interactiveshell.py", line 20, in 
    from prompt_toolkit.formatted_text import PygmentsTokens
ModuleNotFoundError: No module named 'prompt_toolkit.formatted_text'

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

   conda upgrade notebook

   conda upgrade jupyter

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

pip3 install --upgrade prompt-toolkit==2.0.4

升级版本之后的,就能正常运行了
解决anaconda3.6安装jupyter notebook 报错的坑【The kernel has died, and the automatic restart has failed.】_第2张图片

参考网址:

  1. https://blog.csdn.net/cl185303590/article/details/82904491

你可能感兴趣的:(python)