Python 永远重复“内核死了,重新启动”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/39652946/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 22:32:21  来源:igfitidea点击:

Repeated "Kernel died, restarting" forever

pythonjupyterqtconsolejupyter-console

提问by Evgeni Sergeev

When I attempt to run

当我尝试跑步时

$ jupyter qtconsole

The console shows up, with the message

控制台出现,并显示消息

Kernel died, restarting
________________________
Kernel died, restarting
________________________
Kernel died, restarting
________________________
Kernel died, restarting
________________________
Kernel died, restarting
________________________

Which continues.

继续。

Trying $ jupyter qtconsole --debugdidn't print anything else, and neither has adding

尝试$ jupyter qtconsole --debug没有打印任何其他内容,也没有添加

c.Application.log_level = 0
c.Session.debug = True

into $USERHOME/.jupyter/jupyter_qtconsole_config.py

进入 $USERHOME/.jupyter/jupyter_qtconsole_config.py

Also, I found nothing in $USERHOME/.ipython/profile_default/log/and the other directories around there.

此外,我$USERHOME/.ipython/profile_default/log/在那里和周围的其他目录中什么也没找到。

Nothing has changed in my configuration since last time I started up jupyter-qtconsole.

自从我上次启动以来,我的配置没有任何变化jupyter-qtconsole

How can I at least find out what's going wrong with the kernel? Surely there is some option in Jupyter to get the kernel's STDERR output to see what exception had upset it?

我怎样才能至少找出内核出了什么问题?Jupyter 中肯定有一些选项可以获取内核的 STDERR 输出,看看是什么异常扰乱了它?

回答by Lynne

Check the log. I had the same problem and my log shows no module named ipykernel_launcher. So, I just pip install ipykerneland solve the problem.

检查日志。我有同样的问题,我的日志显示no module named ipykernel_launcher. 所以,我只是pip install ipykernel和解决问题。

回答by Zied KEFI

I tried several solutions and finally i found one which really works. You just have to add an exception to your antivirus and/or firewall. I currently use Avast, so adding an exception concerning the folder where i installed Anaconda and the virtual environments solved the problem and now Spyder works as a charm.

我尝试了几种解决方案,最后我找到了一种真正有效的解决方案。您只需要为您的防病毒软件和/或防火墙添加一个例外。我目前使用 Avast,所以添加一个关于我安装 Anaconda 和虚拟环境的文件夹的例外解决了这个问题,现在 Spyder 可以作为一个魅力。

回答by ketankk

Run this-

运行这个 -

conda remove ipykernel ipython jupyter_client jupyter_core traitlets ipython_genutils

conda clean -tipsy

conda install ipykernel ipython jupyter_client jupyter_core traitlets ipython_genutils

jupyter notebook

回答by Bruce Yo

Encountered this problem when try to use pandas to read data in clipboard, tried many times in Spyder editor which is from the Anaconda3. I have also tried to solve the problem by updating the Spyder and other Anaconda3 packages, but failed to solve it.

尝试使用pandas读取剪贴板中的数据时遇到这个问题,在Anaconda3的Spyder编辑器中尝试了很多次。我也尝试通过更新Spyder和其他Anaconda3软件包来解决问题,但未能解决。

Finally, without using the Anaconda3, in another PC install python 3.5.3, then pip install pandas, the error dismissed.

最后,在不使用 Anaconda3 的情况下,在另一台 PC 上安装 python 3.5.3,然后 pip install pandas,错误消除。

回答by Ivan D.

I run

我跑

spyder --show-console

when I receive in spyder

当我在 spyder 中收到

Kernel died, restarting

内核死了,重新启动

I see message in console

我在控制台看到消息

Intel MKL FATAL ERROR: Cannot load libmkl_p4m.so or libmkl_p4.so.

英特尔 MKL 致命错误:无法加载 libmkl_p4m.so 或 libmkl_p4.so。

It was helpfull for me

这对我很有帮助

conda install nomkl numpy scipy scikit-learn numexpr
conda remove mkl mkl-service

回答by Evgeni Sergeev

Given that the kernel is another process, I was able to catch the command line it was started with, using Process Explorer. The command line was

鉴于内核是另一个进程,我能够使用进程资源管理器捕获它启动的命令行。命令行是

$ pythonw -m ipykernel -f "$USERHOME/AppData/Roaming/jupyter/runtime/kernel-2744.json"

Then, I just launched pythonand tried importing ipykernel, and got this:

然后,我刚刚启动python并尝试导入ipykernel,得到了这个:

$ python
Python 2.7.12 [...] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import ipykernel
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Programs\Python2712\lib\site-packages\ipykernel\__init__.py", line 2,
 in <module>
    from .connect import *
  File "C:\Programs\Python2712\lib\site-packages\ipykernel\connect.py", line 13,
 in <module>
    from IPython.core.profiledir import ProfileDir
  File "C:\Programs\Python2712\lib\site-packages\IPython\__init__.py", line 48,
in <module>
    from .core.application import Application
  File "C:\Programs\Python2712\lib\site-packages\IPython\core\application.py", l
ine 25, in <module>
    from IPython.core import release, crashhandler
  File "C:\Programs\Python2712\lib\site-packages\IPython\core\crashhandler.py",
line 28, in <module>
    from IPython.core import ultratb
  File "C:\Programs\Python2712\lib\site-packages\IPython\core\ultratb.py", line
119, in <module>
    from IPython.core import debugger
  File "C:\Programs\Python2712\lib\site-packages\IPython\core\debugger.py", line
 36, in <module>
    from IPython.utils import PyColorize, ulinecache
  File "C:\Programs\Python2712\lib\site-packages\IPython\utils\PyColorize.py", l
ine 55, in <module>
    from IPython.utils.py3compat import PY3
  File "C:\Programs\Python2712\lib\site-packages\IPython\utils\py3compat.py", li
ne 296, in <module>
    PYPY = platform.python_implementation() == "PyPy"
AttributeError: 'module' object has no attribute 'python_implementation'
>>> exit()

And this quickly led to the problem, as described in this answer, being that the directory I was trying to start jupyter qtconsolein had a subdirectory called platform, which conflicted with the name of a module.

这很快导致了问题,如本答案所述,因为我试图开始的目录jupyter qtconsole有一个名为 的子目录platform,它与模块的名称冲突。

While this fixes this specific instance of "Kernel died, restarting", the general question still stands: how to make sure that the stacktrace, like the one above, is reported to the user of Jupyter console, instead of the kernel dying silently?

虽然这修复了“内核死了,重新启动”的这个特定实例,但一般问题仍然存在:如何确保堆栈跟踪,如上面的那个,被报告给 Jupyter 控制台的用户,而不是内核静默死亡?

回答by Fatkhm

I'm having the similar problem when I run import Tensorflow as tf. After downgrading to the Tensorflow 1.5 version, the problem was resolved.

我在运行时遇到了类似的问题import Tensorflow as tf。降级到Tensorflow 1.5版本后,问题解决。

Try uninstalling TensorFlow:

尝试卸载 TensorFlow:

pip uninstall tensorflow

pip uninstall tensorflow

and then reinstalling 1.5:

然后重新安装 1.5:

pip install tensorflow==1.5

pip install tensorflow==1.5

回答by MD004

If the working directory where jupyter qtconsoleis launched from contains some special characters, the "Kernel died, restarting" error may occur repeatedly.

如果启动的工作目录中jupyter qtconsole包含一些特殊字符,可能会反复出现“ Kernel dead, restarting”错误。

For me, I had launched jupyter qtconsolefrom a working directory whose path contained spaces and ampersands (&). When I change directory to root drive (D:/ in my case) the problem goes away.

对我来说,我是jupyter qtconsole从一个工作目录启动的,该目录的路径包含空格和与符号 (&)。当我将目录更改为根驱动器(在我的情况下为 D:/)时,问题就消失了。

回答by Thabang

Jupyter_client and jupyter_core releases have been made available (and contain the fix for this issue), would you mind trying the following:

Jupyter_client 和 jupyter_core 版本已经可用(并包含针对此问题的修复程序),您是否介意尝试以下操作:

1. pip install jupyter_client --upgrade - this should replace your modified jupyter_client package with release 5.3.4 and install the updated version of jupyter_core (4.6.0)

1. pip install jupyter_client --upgrade - 这应该用版本 5.3.4 替换修改后的 jupyter_client 包并安装 jupyter_core (4.6.0) 的更新版本

2. If you find that jupyter_core is NOT 4.6.0 - please try pip install jupyter_core --upgrade.

2. 如果您发现 jupyter_core 不是 4.6.0 - 请尝试 pip install jupyter_core --upgrade。

Check out the thread here: https://github.com/jupyter/notebook/issues/4907

在此处查看线​​程:https: //github.com/jupyter/notebook/issues/4907

回答by Pbl

I had the same problem. I deleted the content at C:\Users\youruser\AppData\Roaming\jupyter\runtime then runs again jupyter notebook. it was helpful for me.

我有同样的问题。我删除了 C:\Users\youruser\AppData\Roaming\jupyter\runtime 中的内容,然后再次运行 jupyter notebook。这对我很有帮助。