russ
July 4, 2024, 8:20pm
1
Plotly is not rendering on my jupyterlab setup… it just leaves an empty space, but no interactive plot, and no static plot either!
The same plotly sample does render on another jupyter lab setup.
The test plot code is this one:
import plotly.graph_objects as go
fig = go.Figure(data=go.Scatter(y=[2, 3, 1]))
fig.show()
The jupyterlab kernel has these relevant installs:
$ jupyter --version
Selected Jupyter core packages...
IPython : 8.26.0
ipykernel : 6.29.5
ipywidgets : 8.1.3
jupyter_client : 8.6.2
jupyter_core : 5.7.2
jupyter_server : 2.14.1
jupyterlab : 4.2.3
nbclient : 0.10.0
nbconvert : 7.16.4
nbformat : 5.10.4
notebook : not installed
qtconsole : not installed
traitlets : 5.14.3
$ pip freeze | egrep "jup|nbf|kale|plotly"
jupyter-dash==0.4.2
jupyter-events==0.10.0
jupyter-lsp==2.2.5
jupyter_client==8.6.2
jupyter_core==5.7.2
jupyter_server==2.14.1
jupyter_server_terminals==0.5.3
jupyterlab==4.2.3
jupyterlab_pygments==0.3.0
jupyterlab_server==2.27.2
jupyterlab_widgets==3.0.11
kaleido==0.2.1
nbformat==5.10.4
plotly==5.22.0
Is there something else I need to do to make plotly work in jupyterlab?
@russ yes, you need to downgrade to jupyter 3.9
Plotly and Jupiter 4 are not really compatible.
1 Like
russ
July 4, 2024, 9:07pm
3
Thanks, @AIMPED . I was wondering if that might be the case.
That is unfortunate, since JupyterLab v4 was release almost a year ago . I suppose it is reasonable to expect that the Plotly team would focus on Dash vs Jupyter, but… … going to be interesting to try and downgrade my jupyterhub/jupyterlab setup. I do really want fast/interactive plotly plots, though!
russ
July 4, 2024, 9:12pm
4
Been reading this “Does plotly work with Jupyterlab 4” post…
Actually I am able to use plotly==5.15 with Jupyter Lab 4, so the latest version probably works well too.
@adamschroeder maybe you meant that there is still some work remaining to get dash, not plotly, compatible with Jupyter Lab 4?
Seems like some have had some luck on that thread? It seems to require strictly pinned versions of a few things, which is not ideal. Will probably just backtrack to jupyterlab < 4.
russ
July 4, 2024, 9:24pm
5
FIXED! I now have interactive plotly plots working with jupyterlab 4.2! No need to downgrade to v3.x.
I went looking in github to see if there were known issues and/or anything I could contribute back to fix this problem… and I found this awesome post:
opened 10:00PM - 12 Sep 23 UTC
I'm trying to install the lab extension for JupyterLab v4.0.5 with the command:
…
```bash
$ 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](https://github.com/plotly/plotly.py/blob/11b4936dd7efaf16a6ca1ab2cb936b2f04047e18/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.
The magic trick required is to install plotly in the python environment that is running jupyterlab (and jupyterhub in my case). Works great now!!
1 Like
import plotly.io as pio
pio.renderers.default = 'iframe'
Solves this problem without messing around with versions and dependencies.