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

extension "jupyterlab-plotly" does not yet support the current version of JupyterLab (v4) #4354

Open
bsdz opened this issue Sep 12, 2023 · 23 comments
Assignees
Labels
feature something new P2 considered for next cycle

Comments

@bsdz
Copy link

bsdz commented Sep 12, 2023

I'm trying to install the lab extension for JupyterLab v4.0.5 with the command:

$ jupyter labextension install  jupyterlab-plotly
(Deprecated) Installing extensions with the jupyter labextension install command is now deprecated 
and will be removed in a future major version of JupyterLab.

Users should manage prebuilt extensions with package managers like pip and conda, and extension 
authors are encouraged to distribute their extensions as prebuilt packages
/pyenvs/jupyterlab-4.x/.venv/lib/python3.10/site-packages/jupyterlab/debuglog.py:56: 
   UserWarning: An error occurred. warnings.warn("An error occurred.")
/pyenvs/jupyterlab-4.x/.venv/lib/python3.10/site-packages/jupyterlab/debuglog.py:57: 
   UserWarning: ValueError: The extension "jupyterlab-plotly" does not yet support the current version of JupyterLab.


Conflicting Dependencies:
JupyterLab        Extension      Package
>=2.0.0 <3.0.0    >=1.2.3 <2.0.0 @lumino/messaging
>=2.0.1 <3.0.0    >=1.8.1 <2.0.0 @lumino/widgets
  warnings.warn(msg[-1].strip())
/pyenvs/jupyterlab-4.x/.venv/lib/python3.10/site-packages/jupyterlab/debuglog.py:58: UserWarning: See 
the log file for details: /tmp/jupyterlab-debug-l5ilibax.log
  warnings.warn(f"See the log file for details: {log_path!s}")

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.

@ned2
Copy link
Contributor

ned2 commented Oct 12, 2023

@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 jupyterlab and ipywidgets. (Note there are minimum version indicated in the docs)

@bsdz
Copy link
Author

bsdz commented Oct 12, 2023

@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 jupyterlab and ipywidgets. (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.

@ned2
Copy link
Contributor

ned2 commented Oct 12, 2023

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?

@m-erhardt
Copy link

I guess I am facing the same issue.

I run jupyterlab==4.0.7 and ipywidgets==8.1.1 (same issue with jupyterlab==4.0.6) behind jupyterhub==4.0.2 with dockerspawner==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 iframe renderer. 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...

@sarahscheffler
Copy link

I am having the same issue in TLJH (jupyterlab 4.0.7) running on a small Ubuntu 22.04 server. plotly 5.18.0 and ipywidgets 8.1.1 installed 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.2

@m-erhardt
Copy link

I was able to fix this issue by adding plotly to 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.0

Kernel venv 1

[...]
plotly==4.14.3
[...]

Kernel venv 2

[...]
plotly==5.11.0
[...]

@Coding-with-Adam
Copy link
Contributor

Thanks 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?

@m-erhardt
Copy link

@Coding-with-Adam exactly.

I made no other changes besides of bumping jupyterlab from 4.0.5 all the way up to 4.0.9 in the course of this issue.
jupyterlab==4.0.9 without plotly did not work as well.

The requirements.txt for my JupyterLab venv contains exactly these three packages.

@bsdz
Copy link
Author

bsdz commented Dec 12, 2023

@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?

@m-erhardt
Copy link

@bsdz

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.

@bsdz
Copy link
Author

bsdz commented Dec 13, 2023

@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.

@lahwaacz
Copy link

lahwaacz commented Feb 2, 2024

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:1243183

@m-erhardt
Copy link

m-erhardt commented Feb 5, 2024

@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 the jupyterlab-plotly extension.

You can check if the extension is present by running jupyter labextension list in your shell.

As the jupyterlab-plotly extension is not available as Python-package from PyPi yet I had to install it the old-fashioned way by running jupyter 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.

@lahwaacz
Copy link

lahwaacz commented Feb 5, 2024

@m-erhardt The JupyterLab Support section in the README says that jupyter labextension install must 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.

@gvwilson
Copy link
Contributor

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

@lahwaacz
Copy link

@gvwilson Can you comment on #4354 (comment) and #4354 (comment)? Or is the Plotly team itself not sure if JupyterLab v4 is fully supported? 🤷

@sjdemartini
Copy link

JupyterLab v3 has reached "end of maintenance" as of 2.5 months ago (May 15, 2024): https://blog.jupyter.org/jupyterlab-3-end-of-maintenance-879778927db2

So ideally plotly (and jupyterlab-plotly) should be updated to have explicit support for the currently-maintained version of JupyterLab, which is v4.

As of today, the latest plotly version 5.23.0 reports as incompatible:

❯ jupyter labextension list --verbose

JupyterLab v4.2.4
/path/to/env/share/jupyter/labextensions
        ...
        jupyterlab-plotly v5.23.0 enabled  X


   The following extensions may be outdated or specify dependencies that are incompatible with the current version of jupyterlab:
        jupyterlab-plotly

   If you are a user, check if an update is available for these packages.
   See below for the details.


"[email protected]" is not compatible with the current JupyterLab
Conflicting Dependencies:
JupyterLab        Extension              Package
>=2.0.0 <3.0.0    >=1.2.3 <2.0.0         @lumino/messaging
>=2.3.1-alpha.0 <3.0.0>=1.8.1 <2.0.0         @lumino/widgets

I see a PR was opened that should hopefully address this #4685, so thanks in advance for the effort to get plotly up to date!

@gvwilson gvwilson added P3 backlog feature something new P2 considered for next cycle and removed P3 backlog labels Aug 12, 2024
@marthacryan
Copy link
Collaborator

marthacryan commented Dec 6, 2024

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 install command, 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 - just pip install plotly. Are you having issues using plotly in jupyter lab/notebook?

@lahwaacz
Copy link

lahwaacz commented Dec 6, 2024

Are you having issues using plotly in jupyter lab/notebook?

@marthacryan Yes, see #4354 (comment)

@marthacryan
Copy link
Collaborator

@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 using Figure works for you (of course we'll still want to make sure FigureWidget works, 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 out pip install --upgrade --pre plotly and seeing if it helps? You'll also need to pip install anywidget if you don't already have that.

@lahwaacz
Copy link

lahwaacz commented Dec 8, 2024

@marthacryan Based on the plotly documentation, it seems that the interaction between plotly and jupyterlab is based on FigureWidget. Displaying the plain static Figure objects 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.0 in 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 on jupyter is 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.

@WannesDeVosWork
Copy link

@marthacryan, I tried the --pre version of plotly and this fixes the issue for me.

@gvwilson
Copy link
Contributor

gvwilson commented Dec 9, 2024

@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 ([email protected]) I'd be happy to follow up with you then - I'd like to make sure you're included in discussions. thanks - Greg

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature something new P2 considered for next cycle
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants