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 · 17 comments · May be fixed by #4685
Open

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

bsdz opened this issue Sep 12, 2023 · 17 comments · May be fixed by #4685
Assignees
Labels
feature something new P2 needed for current 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? 🤷

@gvwilson gvwilson reopened this Jul 13, 2024
@likewei92 likewei92 linked a pull request Jul 22, 2024 that will close this issue
23 tasks
@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 not needed for current cycle feature something new P2 needed for current cycle and removed P3 not needed for current cycle labels Aug 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature something new P2 needed for current cycle
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants