python - Jupyter notebook 死内核

标签 python jupyter-notebook

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

[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 时,它似乎不起作用。

最佳答案

这是一个常见问题。

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”不同。

关于python - Jupyter notebook 死内核,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35213780/

相关文章:

Python - 获取浏览器被重定向到的网址

python - 加载图形然后用它来构建 tflite?

Python 3.4 程序从字符串生成子字符串集没有给出正确的输出

python - 如何在Python中使用Openpyxl对多行Excel行进行平均?

python - Matplotlib x 轴重叠

python - Jupyter Notebook 未从 Anaconda Navigator 启动

python - 在appengine中添加新应用程序

linux - 如何在Windows 10的Linux子系统中启动jupyter笔记本?

python - 未找到模块错误 : No module named 'chart_studio'

python - Jupyter Notebook 不会导入 matplotlib,尽管它似乎已安装