Styvane Styvane - 1 year ago 342
Python Question

The kernel has died, and the automatic restart has failed

I am getting the following

when I run
ipython notebook
from directory with contains a file named

So my question is WHY? because everything is perfect when I rename or remove the file.

Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/me/.virtualenvs/demo/lib/python3.4/site-packages/IPython /", line 48, in <module>
from .core.application import Application
File "/home/me/.virtualenvs/demo/lib/python3.4/site-packages/IPython /core/", line 40, in <module>
from IPython.core import release, crashhandler
File "/home/me/.virtualenvs/demo/lib/python3.4/site-packages/IPython /core/", line 28, in <module>
from IPython.core import ultratb
File "/home/me/.virtualenvs/demo/lib/python3.4/site-packages/IPython/core/", line 110, in <module>
from IPython.core import debugger
File "/home/me/.virtualenvs/demo/lib/python3.4/site-packages/IPython/core/", line 59, in <module>
from pdb import Pdb as OldPdb
File "/usr/local/lib/python3.4/", line 135, in <module>
class Pdb(bdb.Bdb, cmd.Cmd):
AttributeError: 'module' object has no attribute 'Cmd'
2015-01-14 22:23:36.895 [NotebookApp] WARNING | KernelRestarter: restart failed
2015-01-14 22:23:36.896 [NotebookApp] WARNING | Kernel 1005e1cf-b1b4-4f9d- af22-e65c310cfa51 died, removing from map.
ERROR:root:kernel 1005e1cf-b1b4-4f9d-af22-e65c310cfa51 restarted failed!

Answer Source

The last lines of your traceback show that CPython's module pdb is being imported while IPython starts up. Line 72 of the source shows that another module called cmd is imported by "".

The Python docs show the following order when searching for imports, which I believe is the same for IPython:

  1. Current working directory
  3. Installation dependent defaults

Since the startup process involves an import of a module called cmd and there is a file called "" in the first place the interpreter looks, it attempts to import that file, which of course doesn't have the things it's looking for. Specifically, your file "" doesn't have the Cmd class, so the AttributeError is raised.

Removing or renaming "" in your current working directory will resolve the issue.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download