Skip to content

ImportError: Please install ipywidgets>=7.0.0 to use the FigureWidget class #4020

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

Closed
tfmark opened this issue Jan 16, 2023 · 11 comments
Closed

Comments

@tfmark
Copy link

tfmark commented Jan 16, 2023

Off the back of #3686 being merged/released I wanted to revisit jupyterlite + ipywidgets + plotly, but I'm immediately failing.

Using the jupyterlite deployed here with a simple example, I get this error (which suggests ipywidgets is not installed):

image

Note that this example is taken from the issue above.

import micropip

await micropip.install("ipywidgets")
await micropip.install("plotly")

###

from ipywidgets import widgets

import plotly.graph_objects as go

widgets.VBox([
    widgets.HTML("<p>Start</p>"),
    go.FigureWidget(go.Scatter(x=[1, 2, 3], y=[1, 4, 9])),
    widgets.HTML("<p>End</p>"),
])

I feel like I must be doing something wrong, but don't understand what.

@nicolaskruchten
Copy link
Contributor

I'm not sure what the status is of our widget with JupyterLite... has it ever worked? I.e. with Plotly 5.11 and ipywidgets 7.7? I'm not sure how JupyterLite handles federated extensions like ours :)

@tfmark
Copy link
Author

tfmark commented Jan 16, 2023

In my local jupyterlite instance, I've discovered that installing plotly and ipywidgets before running jupyterlite build (in addition to the micropip install of plotly and ipywidgets) appears to solve the problem.

image

So I will close out this ticket, and if anyone else stumbles across it they have a potential solution :)

@jtpio
Copy link

jtpio commented Mar 31, 2023

I'm not sure what the status is of our widget with JupyterLite... has it ever worked? I.e. with Plotly 5.11 and ipywidgets 7.7? I'm not sure how JupyterLite handles federated extensions like ours :)

Yes it worked at some point: jupyterlite/jupyterlite#110 (comment)

But currently seems broken: jupyterlite/jupyterlite#950

JupyterLite handles federated extensions the same way, and I don't think there is anything special to Plotly happening somewhere.

Not sure if a later version of plotly changed something, maybe how the renderers are detected.

@nicolaskruchten
Copy link
Contributor

so fig.show() doesn't use our ipywidget pipeline... are you sure that FigureWidget renderered in the past or just Figure?

@jtpio
Copy link

jtpio commented Mar 31, 2023

Yes that was the case in these PRs, and for quite a while after:

Just tried with FigureWidget but getting the following:

Uncaught ReferenceError: require is not defined

image

A guess could be it tries to load the assets as if it was in the classic notebook. But requirejs is not available in lab / lite.

@nicolaskruchten
Copy link
Contributor

I'm not sure what's happening in the screenshot above, but fig.show() always invokes our mime-type renderer, never our widget pathway, even on the FigureWidget class (confusing :( ). The only way to actually use our widget is to have a FigureWidget instance as the output of a cell, which is not what fig.show() does.

@jtpio
Copy link

jtpio commented Mar 31, 2023

Right, but the plotly mimetype used to be rendered fine before.

For a while we had to set os.environ['PLOTLY_RENDERER'] = 'jupyterlab' so it renders in JupyterLite. Although with a later version of plotly it was not necessary anymore.

Maybe we can try to find which version of plotlytriggers the require error and see if there is any related change.

@nicolaskruchten
Copy link
Contributor

Yeah, we should separately find out why the mimetype renderer is failing. I'm still unsure whether the widget ever worked though: do you remember ever seeing a cell containing just plotly.graph_objects.FigureWidget() render an output? In addition to a cell equivalent to just plotly.graph_objects.Figure().show()?

@jtpio
Copy link

jtpio commented Mar 31, 2023

do you remember ever seeing a cell containing just plotly.graph_objects.FigureWidget() render an output? In addition to a cell equivalent to just plotly.graph_objects.Figure().show()?

Not sure, but can do some digging. Happy to track that in a new issue if it is more convenient.

@jtpio
Copy link

jtpio commented Apr 3, 2023

Happy to track that in a new issue if it is more convenient.

Opened #4143 to continue looking into this.

@pioneerRick
Copy link

The problem is still live, my codeagent.train(n_steps=200, n_episodes=2, save_path="agents/") occur the problem below: Please install ipywidgets>=7.0.0 to use the FigureWidget class.

I try many methods to solve this proble, including upgrade my pip version、upgrade ipywidges、re-install in conda command.

If any process , I'll show my solve plan

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

4 participants