Plotly in jupyterlab

Hi renku team,

I’d like to use plotly in a renkulab session. Googling revealed that a jupyterlab extension (jupyterlab-plotly) is needed. I am able to install it in a session but need to restart the session for it to be available.

How can I have this extension whenever I start a jupyterlab session? Do I need to add some line in the Dockerfile or another file?

Thanks for your help!


Hi Lili,

You actually don’t even need the plotly jupyterlab extension. That is only for older versions of jupyterlab. The current one on most (if not all) renku deployments is new enough to not require the extension. If your project is very old though please do the migration through the renku UI. You can find information about whether your project needs a migration under Overview → Status.

If your project has jupyterlab 2.x then you need to add the following line in your dockerfile, in addition to the steps below. The line should be added right after the part that uses the requirements.txt and environment.yaml files to install your python packages.

RUN jupyter labextension install jupyterlab-plotly@5.1.0 @jupyter-widgets/jupyterlab-manager

See this example project: Renku

All I had to do is add the following in the my requirements.txt file:


Commit this change, push, let the image rebuild and when you launch a session with this new image you will be able to plot things in a notebook just like this:

import plotly.graph_objects as go
fig = go.Figure(data=go.Bar(y=[2, 3, 1]))

Hi Tasko,

thanks for your quick reply!

According to pip list, plotly and ipywidgets are installed with the specified version already.

I kept the session running overnight (the one where I installed the jupyterlab extension). This morning, it was able to show plotly plots.
Also, I started another session this morning and it does not show plotly plots.
Both have plotly and ipywidgets with the specified versions installed.

It’s the same project you helped me with this week already. It uses renku 0.16.0 but the knowledge graph is not activated.

Lili I thought that the migration also fully updates your base image for the session but it does not.

In your project you have jupyterlab version 2.x so you need to add the following line in your Dockerfile to make it work:

RUN jupyter labextension install jupyterlab-plotly@5.1.0 @jupyter-widgets/jupyterlab-manager

You should add the line I mention above right after the portion of your Dockerfile that installs the python packages and usually looks like this:

RUN conda env update -q -f /tmp/environment.yml && \
    /opt/conda/bin/pip install -r /tmp/requirements.txt && \
    conda clean -y --all && \
    conda env export -n "root"

Here is an example project with the changes: Renku

It worked!
Thanks, Tasko!