##// END OF EJS Templates
Show traceback, continuing to start kernel if pylab init fails...
MinRK -
Show More
@@ -743,9 +743,6 b' class IPKernelApp(KernelApp, InteractiveShellApp):'
743
743
744 def init_kernel(self):
744 def init_kernel(self):
745
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,
746 kernel = Kernel(config=self.config, session=self.session,
750 shell_socket=self.shell_socket,
747 shell_socket=self.shell_socket,
751 iopub_socket=self.iopub_socket,
748 iopub_socket=self.iopub_socket,
@@ -755,9 +752,31 b' class IPKernelApp(KernelApp, InteractiveShellApp):'
755 )
752 )
756 self.kernel = kernel
753 self.kernel = kernel
757 kernel.record_ports(self.ports)
754 kernel.record_ports(self.ports)
758
755 shell = kernel.shell
759 if self.pylab:
756 if self.pylab:
760 kernel.shell.enable_pylab(gui, import_all=self.pylab_import_all)
757 try:
758 gui, backend = pylabtools.find_gui_and_backend(self.pylab)
759 shell.enable_pylab(gui, import_all=self.pylab_import_all)
760 except Exception:
761 self.log.error("Pylab initialization failed", exc_info=True)
762 # print exception straight to stdout, because normally
763 # _showtraceback associates the reply with an execution,
764 # which means frontends will never draw it, as this exception
765 # is not associated with any execute request.
766
767 # replace pyerr-sending traceback with stdout
768 _showtraceback = shell._showtraceback
769 def print_tb(etype, evalue, stb):
770 print ("Error initializing pylab, pylab mode will not be active", file=io.stderr)
771 print (shell.InteractiveTB.stb2text(stb), file=io.stdout)
772 shell._showtraceback = print_tb
773
774 # send the traceback over stdout
775 shell.showtraceback(tb_offset=0)
776
777 # restore proper _showtraceback method
778 shell._showtraceback = _showtraceback
779
761
780
762 def init_shell(self):
781 def init_shell(self):
763 self.shell = self.kernel.shell
782 self.shell = self.kernel.shell
General Comments 0
You need to be logged in to leave comments. Login now