ipython notebook - kernel dies if matplotlib is not installed #990

Closed
thisch opened this Issue Nov 10, 2011 · 3 comments

Projects

None yet

3 participants

@thisch
thisch commented Nov 10, 2011

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/<string> in <module>()

/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=<IPython.zmq.ipkernel.IPKernelApp object>, argv=None)

/usr/lib/python2.7/site-packages/IPython/config/application.pyc in catch_config_error(method=<function initialize>, app=<IPython.zmq.ipkernel.IPKernelApp object>, *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=<IPython.zmq.ipkernel.IPKernelApp object>, 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=<IPython.zmq.ipkernel.IPKernelApp object>, argv=None)

/usr/lib/python2.7/site-packages/IPython/config/application.pyc in catch_config_error(method=<function initialize>, app=<IPython.zmq.ipkernel.IPKernelApp object>, *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=<IPython.zmq.ipkernel.IPKernelApp object>, 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=<IPython.zmq.ipkernel.IPKernelApp object>)
    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 core code there should be a check for dependencies which are required for a successful startup of the ipython notebook. Another solution could be to just output an error message inside the notebook browser tab (and deny further edits) instead of showing the ¨kernel has died¨ error message. What do you think?

@fperez
Member
fperez commented Nov 10, 2011

Agreed, we should provide a more informative error here; thanks for the report.

@minrk
Member
minrk commented Nov 10, 2011

See PR #991 for a fix, where not only is the message more informative, but the kernel actually continues to start, even without pylab.

@fperez
Member
fperez commented Nov 10, 2011

MMh, auto-close seems not to be working... Closed by ec0c00d

@fperez fperez closed this Nov 10, 2011
@mdboom mdboom pushed a commit to mdboom/ipython that referenced this issue Dec 2, 2011
@minrk minrk Show traceback, continuing to start kernel if pylab init fails
Error message goes directly over stderr (and traceback over stdout),
rather than as a pyerr message, which is associated with a particular
frontend, and thus ignored because startup actions were not requested
by anyone.

This better matches the terminal behavior, where `ipython --pylab` without matplotlib
installed shows a traceback, but continues to start.

In the qtconsole the traceback will come in below the banner, but in the notebook
the message will not arrive until after the first execution.

closes gh-990, closes gh-991.
ec0c00d
@mattvonrocketstein mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this issue Nov 3, 2014
@minrk minrk Show traceback, continuing to start kernel if pylab init fails
Error message goes directly over stderr (and traceback over stdout),
rather than as a pyerr message, which is associated with a particular
frontend, and thus ignored because startup actions were not requested
by anyone.

This better matches the terminal behavior, where `ipython --pylab` without matplotlib
installed shows a traceback, but continues to start.

In the qtconsole the traceback will come in below the banner, but in the notebook
the message will not arrive until after the first execution.

closes gh-990, closes gh-991.
8a84deb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment