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

%matplotlib magic command - gives ModuleNotFoundError #86

Closed
gaitskell opened this issue Mar 13, 2018 · 4 comments
Closed

%matplotlib magic command - gives ModuleNotFoundError #86

gaitskell opened this issue Mar 13, 2018 · 4 comments

Comments

@gaitskell
Copy link

The basic magic command
%matplotlib
reports an error

%matplotlib interactive also reports an error

%matplotlib


ModuleNotFoundError Traceback (most recent call last)
/usr/lib/python3.6/tkinter/init.py in ()
36 try:
---> 37 import _tkinter
38 except ImportError as msg:

ModuleNotFoundError: No module named '_tkinter'

During handling of the above exception, another exception occurred:

ImportError Traceback (most recent call last)
in ()
----> 1 get_ipython().magic('matplotlib')

/usr/local/lib/python3.6/dist-packages/IPython/core/interactiveshell.py in magic(self, arg_s)
2158 magic_name, _, magic_arg_s = arg_s.partition(' ')
2159 magic_name = magic_name.lstrip(prefilter.ESC_MAGIC)
-> 2160 return self.run_line_magic(magic_name, magic_arg_s)
2161
2162 #-------------------------------------------------------------------------

/usr/local/lib/python3.6/dist-packages/IPython/core/interactiveshell.py in run_line_magic(self, magic_name, line)
2079 kwargs['local_ns'] = sys._getframe(stack_depth).f_locals
2080 with self.builtin_trap:
-> 2081 result = fn(*args,**kwargs)
2082 return result
2083

in matplotlib(self, line)

/usr/local/lib/python3.6/dist-packages/IPython/core/magic.py in (f, *a, **k)
186 # but it's overkill for just that one bit of state.
187 def magic_deco(arg):
--> 188 call = lambda f, *a, **k: f(*a, **k)
189
190 if callable(arg):

/usr/local/lib/python3.6/dist-packages/IPython/core/magics/pylab.py in matplotlib(self, line)
98 print("Available matplotlib backends: %s" % backends_list)
99 else:
--> 100 gui, backend = self.shell.enable_matplotlib(args.gui)
101 self._show_matplotlib_backend(args.gui, backend)
102

/usr/local/lib/python3.6/dist-packages/IPython/core/interactiveshell.py in enable_matplotlib(self, gui)
2948 gui, backend = pt.find_gui_and_backend(self.pylab_gui_select)
2949
-> 2950 pt.activate_matplotlib(backend)
2951 pt.configure_inline_support(self, backend)
2952

/usr/local/lib/python3.6/dist-packages/IPython/core/pylabtools.py in activate_matplotlib(backend)
307
308 import matplotlib.pyplot
--> 309 matplotlib.pyplot.switch_backend(backend)
310
311 # This must be imported last in the matplotlib series, after

@craigcitro
Copy link
Contributor

Ah, it looks like we need to install python3-tk by default to make %matplotlib work. I'll work on getting that added.

That said, I don't know how well any of the other MPL backends will work in Colab -- what are you trying to do? 😀

@marksandler2
Copy link
Contributor

the only type of matplotlib backend that is supported is
%matplotlib inline,

anything else can't possibly work with remote runtimes since it requires x-forwarding

@Nestak2
Copy link

Nestak2 commented Aug 4, 2019

Now, that Ipywidgets support has been added to colab is this issue solved? I still can't create interactive plots in colab with %matplotlib notebook.

@blois
Copy link
Contributor

blois commented Aug 5, 2019

At a glance, %matplotlib notebook doesn't use widgets directly but instead uses the IPython.notebook.kernel.comm_manager API. It also requires jquery to be present.

From jupyterlab/jupyterlab#2948 it looks like JupyterLab is now requiring %matplotlib ipympl. This leverages the widget module 'jupyter-matplotlib' which is currently not supported in Colab.

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

5 participants