ipython/ipython — Issue #990: ipython notebook - kernel dies if matplotlib is not installed
Author: thisch
Created: 2011-11-10 21:38:33+00:00
State: open

I got the following backtrace while loading an example notebook file in docs/examples/notebook:

# ipython notebook --pylab=inline
[NotebookApp] Using existing profile dir: u'/home/thomas/.config/ipython/profile_default'
[NotebookApp] The IPython Notebook is running at: http://127.0.0.1:8888
[1110/222429:ERROR:nss_util.cc(80)] Failed to create /home/thomas/.pki/nssdb directory.
WARNING:root:404 GET /static/mathjax/MathJax.js?config=TeX-AMS_HTML (127.0.0.1) 0.64ms
[NotebookApp] Kernel started: 6b8f132c-6e72-4441-8b87-e4bde375adcc
[IPKernelApp] To connect another client to this kernel, use:
[IPKernelApp] --existing kernel-6b8f132c-6e72-4441-8b87-e4bde375adcc.json
[NotebookApp] Connecting to: tcp://127.0.0.1:44514
[NotebookApp] Connecting to: tcp://127.0.0.1:59769
[NotebookApp] Connecting to: tcp://127.0.0.1:51183
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
/home/thomas/gitrepos/ipython/docs/examples/notebooks/ in ()

/usr/lib/python2.7/site-packages/IPython/zmq/ipkernel.pyc in main()
787 """Run an IPKernel as an application"""
788 app = IPKernelApp.instance()
--> 789 app.initialize()
790 app.start()
791

/usr/lib/python2.7/site-packages/IPython/zmq/ipkernel.pyc in initialize(self=, argv=None)

/usr/lib/python2.7/site-packages/IPython/config/application.pyc in catch_config_error(method=, app=, *args=(None,), **kwargs={})
82 """
83 try:
---> 84 return method(app, *args, **kwargs)
global d = undefined
global Sg = undefined
global xq = undefined
global j = undefined
global D = undefined
global t = undefined
global k = undefined
global rM = undefined
global n = undefined
global q = undefined
85 except (TraitError, ArgumentError) as e:
86 app.print_description()

/usr/lib/python2.7/site-packages/IPython/zmq/ipkernel.pyc in initialize(self=, argv=None)
737 @catch_config_error
738 def initialize(self, argv=None):
--> 739 super(IPKernelApp, self).initialize(argv)
740 self.init_shell()
741 self.init_extensions()

/usr/lib/python2.7/site-packages/IPython/zmq/kernelapp.pyc in initialize(self=, argv=None)

/usr/lib/python2.7/site-packages/IPython/config/application.pyc in catch_config_error(method=, app=, *args=(None,), **kwargs={})
82 """
83 try:
---> 84 return method(app, *args, **kwargs)
global d = undefined
global Sg = undefined
global xq = undefined
global j = undefined
global D = undefined
global t = undefined
global k = undefined
global rM = undefined
global n = undefined
global q = undefined
85 except (TraitError, ArgumentError) as e:
86 app.print_description()

/usr/lib/python2.7/site-packages/IPython/zmq/kernelapp.pyc in initialize(self=, argv=None)
287 self.write_connection_file()
288 self.init_io()
--> 289 self.init_kernel()
290
291 def start(self):

/usr/lib/python2.7/site-packages/IPython/zmq/ipkernel.pyc in init_kernel(self=)
745
746 if self.pylab:
--> 747 gui, backend = pylabtools.find_gui_and_backend(self.pylab)
748
749 kernel = Kernel(config=self.config, session=self.session,

/usr/lib/python2.7/site-packages/IPython/lib/pylabtools.pyc in find_gui_and_backend(gui='inline')
195 """
196
--> 197 import matplotlib
198
199 if gui and gui != 'auto':

ImportError: No module named matplotlib

Somewhere in the code there should be a check for dependencies which are required for a successful the startup of the ipython notebook. Another solution could be to just output an error message inside the notebook browser tab instead of showing the ¨kernel has died¨ error message. What do you think?