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

The example notebook does not work on Google Colab #336

Closed
miohtama opened this issue Jul 23, 2021 · 7 comments
Closed

The example notebook does not work on Google Colab #336

miohtama opened this issue Jul 23, 2021 · 7 comments

Comments

@miohtama
Copy link

Describe the issue

The example notebook fails on Google Colab

  1. Click https://colab.research.google.com/github/matplotlib/ipympl/blob/master/examples/ipympl.ipynb
  2. Add and run !pip install ipympl
  3. Click Runtime > Restart and run all

Versions

 ipympl in /usr/local/lib/python3.7/dist-packages (0.7.0)

The ipympl fails in the section of Interactions with other widgets and layouting.

---------------------------------------------------------------------------

TraitError                                Traceback (most recent call last)

<ipython-input-13-4a044b406030> in <module>()
     13     center=fig.canvas,
     14     footer=widgets.Button(icon='check'),
---> 15     pane_heights=[0, 6, 1]
     16 )

9 frames

/usr/local/lib/python3.7/dist-packages/traitlets/traitlets.py in error(self, obj, value, error, info)
    688                     e = "The '%s' trait expected %s, not %s." % (
    689                         self.name, self.info(), describe("the", value))
--> 690                 raise TraitError(e)
    691 
    692     def get_metadata(self, key, default=None):

TraitError: The 'center' trait of an AppLayout instance expected a Widget or None, not the FigureCanvasAgg at '0x7f0ec0de9750'.

image

@martinRenou
Copy link
Member

Yep. Unfortunately ipywidgets is supported in colab but not sub-widgets-packages like ipympl.

@ianhi
Copy link
Collaborator

ianhi commented Jul 26, 2021

See googlecolab/colabtools#498 and a follow up issue with much more detailed info here: googlecolab/colabtools#1524

@martinRenou
Copy link
Member

ipympl now works in colab!

@thomasaarholt
Copy link
Contributor

@martinRenou I think it no longer works? Running !pip install ipympl at the beginning of this notebook and then restarting the kernel does not yield an interactive figure after running the plt.figure() cell.

https://colab.research.google.com/github/matplotlib/ipympl/blob/master/examples/ipympl.ipynb#scrollTo=rIZyNlcKJJ1k

@martinRenou
Copy link
Member

You need to run the following for it to work:

from google.colab import output
output.enable_custom_widget_manager()

@thomasaarholt
Copy link
Contributor

thomasaarholt commented Mar 15, 2022

Ah! Thanks!

@shaunc
Copy link

shaunc commented Apr 13, 2024

I'm getting this same error in a notebook in vscode. Is there a known workaround?

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