You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
6.0.0 release issue for Shiny for Python apps: "Please install anywidget to use the FigureWidget class" #4996
I am building a shiny for python dashboard. On the latest deployment plotly updated from 5.24.1 -> 6.0.0 and the plots no longer render with the error: "Please install anywidget to use the FigureWidget class". For now I have worked around the issue by specifying the version in my requirements.txt file plotly==5.24.1
For a reproducible example you can use one of the template apps provided by shiny that uses plotly e.g. the dashboard-tips template. Once you have shiny installed you can download the template with shiny create --template dashboard-tips --mode express --github posit-dev/py-shiny-templates, set up a virtual env and install the dependencies in the downloaded requirements.txt file.
Using plotly 6.0.0 the plots fail as shown in the screenshot below:
However, if you downgrade plotly to 5.24.1 the dashboard renders as expected:
Here is the full traceback (from the 6.0.0 version):
Traceback (most recent call last):
File "d:\code\spikes\shiny_experiments.venv\Lib\site-packages\shiny\session_session.py", line 1450, in output_obs
value = await renderer.render()
^^^^^^^^^^^^^^^^^^^^^^^
File "d:\code\spikes\shiny_experiments.venv\Lib\site-packages\shinywidgets_render_widget_base.py", line 87, in render
widget = as_widget(value)
^^^^^^^^^^^^^^^^
File "d:\code\spikes\shiny_experiments.venv\Lib\site-packages\shinywidgets_as_widget.py", line 26, in as_widget
res = _as_widget(x)
^^^^^^^^^^^^^
File "d:\code\spikes\shiny_experiments.venv\Lib\site-packages\shinywidgets_as_widget.py", line 75, in as_widget_plotly
return go.FigureWidget(x.data, x.layout) # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "d:\code\spikes\shiny_experiments.venv\Lib\site-packages\plotly\missing_anywidget.py", line 13, in init
raise ImportError("Please install anywidget to use the FigureWidget class")
ImportError: Please install anywidget to use the FigureWidget class
I agree! One thing I'll note though is that this is identical to the behavior before the 6.0.0 release except that ipywidgets was substituted for anywidget as the package required. We should at the very least update the wording of the error to say pip install anywidget for clarity.
@turbotimon apologies for the slow response - when you say "still now able to get FigureWidget to work with v6.0.0" do you mean "still not able"? thanks - @gvwilson
@gvwilson sorry for the unclear wording. Yes, I meant "still not able". However, I just retried my test example with plotly==6.1.2 anywidget==0.9.18 and it seems to work fine now👍 (There is still a strange behavior in colab tough, but it works in vscode notebooks #5027 (comment))
Activity
igi-chris commentedon Jan 29, 2025
For a reproducible example you can use one of the template apps provided by shiny that uses plotly e.g. the dashboard-tips template. Once you have shiny installed you can download the template with
shiny create --template dashboard-tips --mode express --github posit-dev/py-shiny-templates, set up a virtual env and install the dependencies in the downloaded requirements.txt file.Using plotly 6.0.0 the plots fail as shown in the screenshot below:

However, if you downgrade plotly to 5.24.1 the dashboard renders as expected:

Here is the full traceback (from the 6.0.0 version):
ndrezn commentedon Jan 29, 2025
@marthacryan I see that
anywidgetis only inrequires-optional: https://github.com/plotly/plotly.py/blob/master/packages/python/plotly/requires-optional.txt#L51 Should it go into arequires-jupyteror elsewhere so that it's easier to know what to install?This is a UX recommendation; the fix for this issue @igi-chris might be for Posit to update their templates.
You can also:
manually in your environment to resolve the issue.
marthacryan commentedon Jan 29, 2025
I agree! One thing I'll note though is that this is identical to the behavior before the 6.0.0 release except that
ipywidgetswas substituted foranywidgetas the package required. We should at the very least update the wording of the error to saypip install anywidgetfor clarity.turbotimon commentedon Feb 11, 2025
Please also note this line from the v6.0 release notes (it was the reason why my code failed even with
anywidgetmanually installed):Edit: No, I'm still now able to get FigureWidget to work in v6.0.0. Only downgrading solves the problem: #5027
gvwilson commentedon Jun 17, 2025
@turbotimon apologies for the slow response - when you say "still now able to get FigureWidget to work with v6.0.0" do you mean "still not able"? thanks - @gvwilson
turbotimon commentedon Jun 18, 2025
@gvwilson sorry for the unclear wording. Yes, I meant "still not able". However, I just retried my test example with
plotly==6.1.2 anywidget==0.9.18and it seems to work fine now👍 (There is still a strange behavior in colab tough, but it works in vscode notebooks #5027 (comment))