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 widget not working #132

Closed
doofkatze opened this issue Jul 31, 2019 · 7 comments
Closed

%matplotlib widget not working #132

doofkatze opened this issue Jul 31, 2019 · 7 comments

Comments

@doofkatze
Copy link

doofkatze commented Jul 31, 2019

I've followed the installation instruction and consulted previous posts. But %matplotlib widget still give me error messages.

%matplotlib widget

`---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
in
----> 1 get_ipython().run_line_magic('matplotlib', 'widget')

~/.local/lib/python3.6/site-packages/IPython/core/interactiveshell.py in run_line_magic(self, magic_name, line, _stack_depth)
2305 kwargs['local_ns'] = sys._getframe(stack_depth).f_locals
2306 with self.builtin_trap:
-> 2307 result = fn(*args, **kwargs)
2308 return result
2309

</home/gin/.local/lib/python3.6/site-packages/decorator.py:decorator-gen-108> in matplotlib(self, line)

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

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

~/.local/lib/python3.6/site-packages/IPython/core/interactiveshell.py in enable_matplotlib(self, gui)
3382 gui, backend = pt.find_gui_and_backend(self.pylab_gui_select)
3383
-> 3384 pt.activate_matplotlib(backend)
3385 pt.configure_inline_support(self, backend)
3386

~/.local/lib/python3.6/site-packages/IPython/core/pylabtools.py in activate_matplotlib(backend)
311 matplotlib.rcParams['backend'] = backend
312
--> 313 import matplotlib.pyplot
314 matplotlib.pyplot.switch_backend(backend)
315

/usr/local/lib/python3.6/dist-packages/matplotlib-3.1.0+860.g4edadf965-py3.6-linux-x86_64.egg/matplotlib/pyplot.py in
38 from matplotlib import docstring
39 from matplotlib.backend_bases import FigureCanvasBase
---> 40 from matplotlib.figure import Figure, figaspect
41 from matplotlib.gridspec import GridSpec
42 from matplotlib import rcParams, rcParamsDefault, get_backend, rcParamsOrig

/usr/local/lib/python3.6/dist-packages/matplotlib-3.1.0+860.g4edadf965-py3.6-linux-x86_64.egg/matplotlib/figure.py in
18
19 from matplotlib import rcParams
---> 20 from matplotlib import backends, docstring, projections
21 from matplotlib import version as _mpl_version
22 from matplotlib import get_backend

/usr/local/lib/python3.6/dist-packages/matplotlib-3.1.0+860.g4edadf965-py3.6-linux-x86_64.egg/matplotlib/projections/init.py in
2 from .geo import AitoffAxes, HammerAxes, LambertAxes, MollweideAxes
3 from .polar import PolarAxes
----> 4 from mpl_toolkits.mplot3d import Axes3D
5
6

/usr/lib/python3/dist-packages/mpl_toolkits/mplot3d/init.py in
4 import six
5
----> 6 from .axes3d import Axes3D

/usr/lib/python3/dist-packages/mpl_toolkits/mplot3d/axes3d.py in
30 import matplotlib.transforms as mtransforms
31 from matplotlib.axes import Axes, rcParams
---> 32 from matplotlib.cbook import _backports
33 from matplotlib.colors import Normalize, LightSource
34 from matplotlib.transforms import Bbox

ImportError: cannot import name '_backports' `

@doofkatze
Copy link
Author

even import ipympl gives error although I've installed it

`---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
in
----> 1 import ipympl

ModuleNotFoundError: No module named 'ipympl'`

@thomasaarholt
Copy link
Contributor

thomasaarholt commented Aug 5, 2019

Sounds like you are having trouble with your python installation / virtual environment?

In the terminal, try which python and which jupyter and see if they coincide with where you have installed ipympl.

@vjmayr
Copy link

vjmayr commented Sep 1, 2020

just because I forgot: you did - pip install ipympl - ?

@JimmyPark001
Copy link

In the interactive window, i can only see text/pain and text/html . I think i can figure out this issue if i can change MIME type into Image/png. do you know how i can add that MIME type in VSC?

@himanshuGoyal52
Copy link

same issue ... if you found the result please tell crow

@thomasaarholt
Copy link
Contributor

thomasaarholt commented Jan 13, 2024

Folks, you're commenting on a 4 year old issue. While open, it's likely that your issue is not the same as the original OPs.
Please include a reproducible example, or at least explain what you're doing to produce the error.

The following plot works fine on a new python 3.12 virtual environment. On my mac, I have done:

# created a fresh python environment inside the folder we're in
python -m venv .venv

# activated the python environment
source .venv/bin/activate

# installed the packages we need
pip install notebook ipympl matplotlib

# started jupyter notebook
jupyter notebook
%matplotlib widget

import matplotlib.pyplot as plt

plt.figure()
plt.plot([1,2,3])
image

@martinRenou
Copy link
Member

I'd even suggest opening a new issue with all the needed information for debugging your use case.

Closing this one for triaging. Please stop commenting here 😁

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

6 participants