Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
divaDevDir opened this issue Jul 15, 2013 · 3 comments
Milestone

Comments

@divaDevDir
Copy link

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.

@minrk
Copy link
Member

minrk commented Jul 15, 2013

It is not recommended to start the notebook with --pylab [anything]. It is best to always use the %pylab magic in the notebooks themselves.

@minrk
Copy link
Member

minrk commented Jul 15, 2013

Also, I think support for backend switching may be new in 1.0.

@divaDevDir
Copy link
Author

I agree and realize that, backend switching is a feature available only in the new 1.0 version (not in my 0.13.2 version)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants