鉴于内核是另一个进程,我能够使用 Process Explorer 捕获它启动时使用的命令行。命令行是
$ pythonw -m ipykernel -f "$USERHOME/AppData/Roaming/jupyter/runtime/kernel-2744.json"
然后,我刚刚启动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()
这很快就导致了问题,正如这个答案中所描述的那样,我试图开始的目录jupyter qtconsole
有一个名为 的子目录platform
,它与模块的名称冲突。
虽然这修复了“内核死亡,重新启动”的这个特定实例,但一般问题仍然存在:如何确保堆栈跟踪(如上面的那个)报告给 Jupyter 控制台的用户,而不是内核静默死亡?