Repository navigation
extension "jupyterlab-plotly" does not yet support the current version of JupyterLab (v4) #4354
Description
Activity
@bsdz you no longer need to install a Jupyter extension to use Plotly in JupyterLab. The current Plotly documentation indicates you just need to install the Python packages
jupyterlabandipywidgets. (Note there are minimum version indicated in the docs)@bsdz you no longer need to install a Jupyter extension to use Plotly in JupyterLab. The current Plotly documentation indicates you just need to install the Python packages
jupyterlabandipywidgets. (Note there are minimum version indicated in the docs)I beg to differ. This works in my JupyterLab 3.6.5 set up only if I install the the jupyterlab-plotly extension. The documentation is, unfortunately, wrong here. If I remove the extension from my JupyterLab v3 set up then the plots disappear. They reappear again when I reinstall the extension.
As I said I earlier, I keep my Jupyter virtual environments separate to my active kernels and this is perhaps why i need to install the lab extension.
ah, I'm just going by what the docs say on exactly which version this changes to be simpler. But regardless of whether this works with v3 or not, in your original description of the issue you mentioned you tried with JupyterLab v4, where this should apply.
ahh right, I don't know if using a distinct Jupyter venv from your kernel venvs would impact this. @alexcjohnson do you know how well that setup is supported?
I guess I am facing the same issue.
I run
jupyterlab==4.0.7andipywidgets==8.1.1(same issue withjupyterlab==4.0.6) behindjupyterhub==4.0.2withdockerspawner==12.1.0.
Within my docker-spawned JupyterLab container I also have separate venvs for JupyterLab and my kernels.Plotly plots dont show up. When examinig the raw
.ipynb-file I can see that the cell output is populated with html/css.(jupyter) jupyter labextension list JupyterLab v4.0.7 /opt/pyenvs/jupyter/share/jupyter/labextensions jupyterlab_pygments v0.2.2 enabled X (python, jupyterlab_pygments) jupyterlab-gitlab v4.0.0 enabled OK (python, jupyterlab-gitlab) @jupyter-widgets/jupyterlab-manager v5.0.9 enabled OK (python, jupyterlab_widgets) The following extensions are outdated: jupyterlab_pygments Consider checking if an update is available for these packages.A (non-ideal) workaround is to use the
iframerenderer. This results in the Ploty plots showing as usual.import plotly.io as pio pio.renderers.default = 'iframe'Hints are welcome and if you need further information to narrow down the root cause feel free to ask...
Reacted by jwardbond, Sarah Scheffler, Mike Wilkerson, Sacbe, Zhang Zhen, mikekuzak, Jakub Klinkovský, Marcin Wiśniewski and IlyaI am having the same issue in TLJH (
jupyterlab 4.0.7) running on a small Ubuntu 22.04 server.plotly 5.18.0andipywidgets 8.1.1installed with pip -- my understanding from the docs is that this is all I should need.When creating any plotly fig and running
fig.show(), a blank space appears but without any actual plot.Many thanks to @m-erhardt, because the iframe workaround works to make plotly plots appear for now.
plotly 5.18.0 # installed with pip IPython : 8.16.1 ipykernel : 6.25.2 ipywidgets : 8.1.1 jupyter_client : 8.4.0 jupyter_core : 5.4.0 jupyter_server : 2.8.0 jupyterlab : 4.0.7 nbclient : 0.8.0 nbconvert : 7.9.2 nbformat : 5.9.2 notebook : 7.0.6 qtconsole : not installed traitlets : 5.11.2Reacted by Mike WilkersonI was able to fix this issue by adding
plotlyto the JupyterLab venv.
Apparently this is required when using multiple kernels/venvs and running JupyterLab in a venv of it's own.
It would probably make sense to add this to the Plotly documentation.JupyterLab venv
jupyterlab==4.0.9 ipywidgets==8.1.1 plotly==5.18.0Kernel venv 1
[...] plotly==4.14.3 [...]Kernel venv 2
[...] plotly==5.11.0 [...]Reacted by Russ WarrenReacted by Adam, Alexandre Almeida, Jared Lumpe and Russ WarrenReacted by Russ WarrenThanks for the comment @m-erhardt .
Just to confirm your solution. You got Plotly to work in JupyterLab4 just by adding plotly to the JupyterLab venv?
You didn't have to do anything else?@Coding-with-Adam exactly.
I made no other changes besides of bumping
jupyterlabfrom4.0.5all the way up to4.0.9in the course of this issue.
jupyterlab==4.0.9withoutplotlydid not work as well.The
requirements.txtfor my JupyterLab venv contains exactly these three packages.@m-erhardt, out of curiosity, are your JupyterLab and kernel venvs on the same host? are they using the same user id? if so, do you ensure their separation by setting different JUPYTER_RUNTIME_DIR, JUPYTER_DATA_DIR and JUPYTER_CONFIG_DIR environment variables for each?
As mentioned in my first comment in this issue I use JupyterLab behind JupyterHub and spawn an individual JupyterLab container for each user. So there is complete separation between user-environments.
My venvs are not exatly "on the same host" but within the same container/image (which is somewhat comparable).
So for every user there is one container with one instance of JupyterLab which is always running with the same configuration and environment variables.
In order to run individual notebooks with other Python versions and venvs I registered my other virtual environments as ipykernels.
/opt/pyenvs/${kernel_venv_1}/bin/python -m ipykernel install --prefix=/opt/pyenvs/${jupyterlab_env} --name 'venv1' --display-name 'Venv 1' /opt/pyenvs/${kernel_venv_2}/bin/python -m ipykernel install --prefix=/opt/pyenvs/${jupyterlab_env} --name 'venv2' --display-name 'Venv 2' [...]
This will create kernelspec files at
/opt/pyenvs/${jupyterlab_env}/share/jupyter/kernels/${kernel_venv}/kernel.json.You can then select which kernel to use for each notebook from the JupterLab UI.
The reasoning behind this is that I always want to use the latest version of Python and JupyterLab for security reasons and to profit from recent bug fixes.
But my particular use-case dictates that I need to provide multiple Python versions with pinned package versions for executing notebooks to guarantee reproducible research results.
@m-erhardt , that's interesting thanks. I'm not using JupyterHub, but I do serve my kernels inside & outside of docker containers using Enterprise Gateway. I'm sure I tested installing plotly in both the JupyterLab venv as well as my kernel venvs already but I will give it another go. Tbh I've parked my migration to JLab4 because of several other issues where 3rd party extensions are yet to be updated.
Can you comment on the issue discussed in https://community.plotly.com/t/does-plotly-work-with-jupyterlab-4/76095 ? Specifically, I get these JavaScript errors with plotly 5.18 and jupyterlab 4.0.12 and ipywidgets 8.1.1 and :
Failed to load model class 'FigureModel' from module 'jupyterlab-plotly' P.f.j@http://localhost:8888/lab/extensions/jupyterlab-plotly/static/remoteEntry.70a4f7e7a0383740860d.js:1:7014 P.e/<@http://localhost:8888/lab/extensions/jupyterlab-plotly/static/remoteEntry.70a4f7e7a0383740860d.js:1:1548 P.e@http://localhost:8888/lab/extensions/jupyterlab-plotly/static/remoteEntry.70a4f7e7a0383740860d.js:1:1526 exports@http://localhost:8888/lab/extensions/jupyterlab-plotly/static/133.7957020c5e8bc5703dbc.js?v=7957020c5e8bc5703dbc:1:339 loadClass@http://localhost:8888/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/134.a63a8d293fb35a52dc25.js?v=a63a8d293fb35a52dc25:1:75207 loadModelClass@http://localhost:8888/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/336.ebc7a55ea1768712771f.js?v=ebc7a55ea1768712771f:1:10729 _make_model@http://localhost:8888/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/336.ebc7a55ea1768712771f.js?v=ebc7a55ea1768712771f:1:7517 new_model@http://localhost:8888/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/336.ebc7a55ea1768712771f.js?v=ebc7a55ea1768712771f:1:5137 handle_comm_open@http://localhost:8888/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/336.ebc7a55ea1768712771f.js?v=ebc7a55ea1768712771f:1:3894 134/v/this._handleCommOpen@http://localhost:8888/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/134.a63a8d293fb35a52dc25.js?v=a63a8d293fb35a52dc25:1:73473 _handleCommOpen@http://localhost:8888/static/lab/jlab_core.826ed748f0a8a70a419e.js?v=826ed748f0a8a70a419e:1:1243183Reacted by zhuangyuanjoy@lahwaacz I can't give an definitive answer but based on the class-loading error message
Failed to load model class 'FigureModel' from module 'jupyterlab-plotly'I would guess you are missing thejupyterlab-plotlyextension.You can check if the extension is present by running
jupyter labextension listin your shell.As the
jupyterlab-plotlyextension is not available as Python-package from PyPi yet I had to install it the old-fashioned way by runningjupyter labextension install jupyterlab-plotly.These extensions are present within my JupyterLab 4.0.12 container:
(jupyter) jupyter labextension list JupyterLab v4.0.12 /opt/pyenvs/jupyter/share/jupyter/labextensions jupyterlab-plotly v5.18.0 enabled X jupyterlab_pygments v0.3.0 enabled OK (python, jupyterlab_pygments) jupyterlab-gitlab v4.0.0 enabled OK (python, jupyterlab-gitlab) @jupyter-notebook/lab-extension v7.0.7 enabled OK @jupyter-widgets/jupyterlab-manager v5.0.9 enabled OK (python, jupyterlab_widgets) The following extensions are outdated: jupyterlab-plotly Consider checking if an update is available for these packages.Reacted by Kewei Li and Surya@m-erhardt The JupyterLab Support section in the README says that
jupyter labextension installmust be installed for JupyterLab 2 or earlier. Granted, it also says "The instructions above apply to JupyterLab 3.x" without mentioning version 4, but that also indicates incomplete support for JupyterLab 4.Hi - we are tidying up stale issues and PRs in Plotly's public repositories so that we can focus on things that are still important to our community. Since this one has been sitting for a while, I'm going to close it; if it is still a concern, please add a comment letting us know what recent version of our software you've checked it with so that I can reopen it and add it to our backlog. If you'd like to submit a PR, we'd be happy to prioritize a review, and if it's a request for tech support, please post in our community forum. Thank you - @gvwilson
8 remaining items
Hi! I recently made a PR (#4822) to update our jupyter support and found that this extension is no longer necessary for newer versions of jupyterlab (>=3) and notebook (>=7). If you look at the top of the output of your
jupyter labextension installcommand, you can see: "(Deprecated) Installing extensions with the jupyter labextension install command is now deprecated and will be removed in a future major version of JupyterLab." In fact, you don't need any extension installed to use plotly in these newer versions - justpip install plotly. Are you having issues using plotly in jupyter lab/notebook?Are you having issues using plotly in jupyter lab/notebook?
@marthacryan Yes, see #4354 (comment)
@lahwaacz Oh okay - do you mind sending the code to reproduce that error? It looks like you might be using the
FigureWidget? I'd be curious to see whether just usingFigureworks for you (of course we'll still want to make sureFigureWidgetworks, it would just be a good datapoint to have). In that case, I think you may actually be able to fix this in the newest release of plotly due to the changes in #4823 - do you mind trying outpip install --upgrade --pre plotlyand seeing if it helps? You'll also need topip install anywidgetif you don't already have that.Reacted by WannesDeVosWork@marthacryan Based on the plotly documentation, it seems that the interaction between plotly and jupyterlab is based on
FigureWidget. Displaying the plain staticFigureobjects in Jupyter notebooks is not the same thing as you don't need any JupyterLab extension for that. I think one of those examples was what I was trying to run the last time...I don't understand Plotly's approach to the "support" of various components. There is a difference between "it is supported" and "it just works", since the former is a conscious effort to make it work and the latter might be just "by accident". In the last stable release, 5.24.1, plotly still specifies
jupyterlab ~=3.0in the optional-requirements.txt as well as the disputed JupyterLab Support section in the README. I see that both things changed in the master branch (requires-optional.txt, README). However, the dependency onjupyteris unversioned: ok, so you want to have support for jupyter, but don't say which version is "supported", which is not useful. Can anybody from the Plotly team clearly state if JupyterLab v4 is fully supported? It would be a good idea to reflect this in the requirements file.@marthacryan, I tried the --pre version of plotly and this fixes the issue for me.
Reacted by Martha Cryan@lahwaacz thanks for your feedback - we've been reluctant to pin specific versions of Jupyter and related packages for fear of disrupting things like CI pipelines. We have a clear idea internally of what versions we support in our upcoming release, and you're right, we need to translate that into a support matrix and get it posted soon. However, our priority right now is to wrap up the plotly.py 6.0 release, and the Dash 3.0 release right after it, which means it will be early January before we can produce that. If you would like to mail me (greg.wilson@plot.ly) I'd be happy to follow up with you then - I'd like to make sure you're included in discussions. thanks - Greg
Reacted by Jakub KlinkovskýI've noticed that Plotly 6.0 still requires
jupyterlab~=3.0which excludes 4.0 and newer:https://github.com/plotly/plotly.py/blob/v6.0.0/packages/python/plotly/pyproject.toml#L2
What is the rationale? As far as I can tell there is no
labextensionin plotly anymore since you use anywidget, so I don't see any blocker v3.0.Ah yes I actually was just changing that in this PR: #4970 because I noticed that the pyproject.toml was requiring that. It shouldn't!
Reacted by Jakub Klinkovský and MazzMaLooks like this is fixed as of plotly 6.0.1? I'm able to use plotly 6.0.1 and jupyterlab 4 together without any special workarounds, as far as I can tell.
I have code like
from plotly.offline import iplot import plotly some_fig = plotly.graph_objs.Figure(layout_title_text="my title") some_fig.update_layout( xaxis_title="my x label", yaxis_title="my y label" ) some_fig.add_trace(plotly.graph_objs.Scatter( x=my_x_data, y=my_y_data)) iplot(some_fig)
Does that get anything for you?
Thanks, but unfortunately it the same:
I tried also suggestion from the plotly forum, to use iframe renderer: https://community.plotly.com/t/plotly-not-rendering-in-jupyterlab-just-leaving-an-empty-space/85588/6
And while it does show the figure it's very slow...
My issue turned out to be missing jupyterlab-plotly extension.
I tried to install with
jupyter labextension install jupyterlab-plotly, but it raises conflict with lumino widgets.As I read the extension is automatically installed when installing plotly, I uninstalled plotly then reinstalled, and everything is as expected now, even without iplot.
And BTW, iframe renderer method is not slow, but I had a large data.

I'm trying to install the lab extension for JupyterLab v4.0.5 with the command:
The conflicting dependencies match what I see in the master branch for packages/javascript/jupyterlab-plotly/package.json.
I keep my jupyter virtual environment separate to my working kernels. I'm not sure if there's a different way to install plotly for JupyterLab v4.