【问题标题】:Jupyter notebook dead kernelJupyter notebook 死内核
【发布时间】:2016-05-14 19:38:06
【问题描述】:

所以我尝试修复我的 Jupyter 笔记本(它不允许我导入库),但是,看来我让事情变得更糟了。现在每当我启动笔记本时,内核都会启动,然后立即死亡。我得到的错误如下:

[I 15:00:39.002 NotebookApp] Serving notebooks from local directory: /Users/stephanng/Documents/Coding/IPyNB
[I 15:00:39.002 NotebookApp] 0 active kernels 
[I 15:00:39.003 NotebookApp] The Jupyter Notebook is running at: http://localhost:8888/
[I 15:00:39.003 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[W 15:00:43.558 NotebookApp] Notebook 157 Muon Analysis - Copy.ipynb is not trusted
[I 15:00:44.045 NotebookApp] Kernel started: 152a55a1-e393-4e86-b271-859b924e6a3e
/Users/stephanng/anaconda/envs/py27/bin/python: No module named _signatures; 'ipykernel' is a package and cannot be directly executed
[I 15:00:47.047 NotebookApp] KernelRestarter: restarting kernel (1/5)
/Users/stephanng/anaconda/envs/py27/bin/python: No module named _signatures; 'ipykernel' is a package and cannot be directly executed
[I 15:00:50.059 NotebookApp] KernelRestarter: restarting kernel (2/5)
/Users/stephanng/anaconda/envs/py27/bin/python: No module named _signatures; 'ipykernel' is a package and cannot be directly executed
[I 15:00:53.067 NotebookApp] KernelRestarter: restarting kernel (3/5)
/Users/stephanng/anaconda/envs/py27/bin/python: No module named _signatures; 'ipykernel' is a package and cannot be directly executed
[W 15:00:54.257 NotebookApp] Timeout waiting for kernel_info reply from 152a55a1-e393-4e86-b271-859b924e6a3e
[I 15:00:56.078 NotebookApp] KernelRestarter: restarting kernel (4/5)
WARNING:root:kernel 152a55a1-e393-4e86-b271-859b924e6a3e restarted
/Users/stephanng/anaconda/envs/py27/bin/python: No module named _signatures; 'ipykernel' is a package and cannot be directly executed
[W 15:00:59.094 NotebookApp] KernelRestarter: restart failed
[W 15:00:59.095 NotebookApp] Kernel 152a55a1-e393-4e86-b271-859b924e6a3e died, removing from map.
ERROR:root:kernel 152a55a1-e393-4e86-b271-859b924e6a3e restarted failed!
[W 15:00:59.116 NotebookApp] Kernel deleted before session
[W 15:00:59.117 NotebookApp] 410 DELETE /api/sessions/15eb80b6-d134-4142-96fa-1b1012be280c (::1) 5.42ms referer=http://localhost:8888/notebooks/157%20Muon%20Analysis%20-%20Copy.ipynb

有没有办法解决这个问题?还是我应该完全卸载并重新安装?另外,我该怎么做呢?当我做sudo pip uninstall jupyter 时,它似乎不起作用。

【问题讨论】:

  • 它是 pip uninstall jupyter-core jupyter-client notebook,但是是的,除非你在 virtualenv 中,否则仍然是个坏主意
  • 你对你的笔记本做了什么特别的事情吗? .ipynb is not trusted 表示以某种方式进行了数字签名
  • 我真的相信我让它工作了。我卸载了(基本上所有东西),包括 conda(通过 rm -rf),然后我重新安装了 conda 和 jupyter。它似乎适用于 python2 笔记本
  • 我会删除内核并重新安装它。参考这里stackoverflow.com/a/42647666/7359507
  • 你试过了吗 - pip install "ipython[notebook]" --upgrade

标签: python jupyter-notebook


【解决方案1】:

这是一个常见问题解答。

tl;dr:如果需要,请在笔记本中执行此操作,例如numpy:

import sys
!conda install --yes --prefix {sys.prefix} numpy

请参阅http://jakevdp.github.io/blog/2017/12/05/installing-python-packages-from-jupyter/,详细讨论为什么 Jupyter 环境中的“import foo”与命令行环境中的“import foo”不同。

【讨论】:

    【解决方案2】:

    激活 conda 环境后运行以下命令:

    python -m ipykernel install --user

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-10-24
      • 2018-09-11
      • 2018-12-02
      • 1970-01-01
      • 1970-01-01
      • 2019-08-01
      相关资源
      最近更新 更多