Skip to content

%pylab inline in IPYTHON notebook throws "RuntimeError: Cannot activate multiple GUI eventloops" #3639

@divaDevDir

Description

@divaDevDir

I am on IPython 0.13.2 in Windows XP (32 bit)

If I start through the command "ipython notebook", A cell with "%pylab inline" throws the below error.

Welcome to pylab, a matplotlib-based Python environment [backend: module://IPython.zmq.pylab.backend_inline].
For more information, type 'help(pylab)'.
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-1-550caa57204a> in <module>()
----> 1 get_ipython().magic(u'pylab inline')

C:\Python27\Lib\site-packages\IPython\core\interactiveshell.pyc in magic(self, arg_s)
   2134         magic_name, _, magic_arg_s = arg_s.partition(' ')
   2135         magic_name = magic_name.lstrip(prefilter.ESC_MAGIC)
-> 2136         return self.run_line_magic(magic_name, magic_arg_s)
   2137 
   2138     #-------------------------------------------------------------------------

C:\Python27\Lib\site-packages\IPython\core\interactiveshell.pyc in run_line_magic(self, magic_name, line)
   2060                 args.append(sys._getframe(stack_depth).f_locals)
   2061             with self.builtin_trap:
-> 2062                 result = fn(*args)
   2063             return result
   2064 

C:\Python27\Lib\site-packages\IPython\core\magics\pylab.pyc in pylab(self, parameter_s)

C:\Python27\Lib\site-packages\IPython\core\magic.pyc in <lambda>(f, *a, **k)
    189     # but it's overkill for just that one bit of state.
    190     def magic_deco(arg):
--> 191         call = lambda f, *a, **k: f(*a, **k)
    192 
    193         if callable(arg):

C:\Python27\Lib\site-packages\IPython\core\magics\pylab.pyc in pylab(self, parameter_s)
     86             import_all_status = True
     87 
---> 88         self.shell.enable_pylab(parameter_s, import_all=import_all_status)

C:\Python27\Lib\site-packages\IPython\core\interactiveshell.pyc in enable_pylab(self, gui, import_all)
   2790         # Now we must activate the gui pylab wants to use, and fix %run to take
   2791         # plot updates into account
-> 2792         self.enable_gui(gui)
   2793         self.magics_manager.registry['ExecutionMagics'].default_runner = \
   2794         mpl_runner(self.safe_execfile)

C:\Python27\Lib\site-packages\IPython\zmq\eventloops.pyc in enable_gui(gui, kernel)
    220     loop = loop_map[gui]
    221     if kernel.eventloop is not None and kernel.eventloop is not loop:
--> 222         raise RuntimeError("Cannot activate multiple GUI eventloops")
    223     kernel.eventloop = loop

RuntimeError: Cannot activate multiple GUI eventloops

But If I start through the command "ipython notebook --pylab=inline", A cell with "%pylab inline" works just fine but "%pylab qt" throws the below error.

Welcome to pylab, a matplotlib-based Python environment [backend: Qt4Agg].
For more information, type 'help(pylab)'.
C:\Python27\Lib\site-packages\matplotlib\__init__.py:1033: UserWarning:  This call to matplotlib.use() has no effect
because the the backend has already been chosen;
matplotlib.use() must be called *before* pylab, matplotlib.pyplot,
or matplotlib.backends is imported for the first time.

  warnings.warn(_use_error_msg)

Basically I could not change the matplotlib backend dynamically.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions