9

Plotly is not working in Jupyterlab. I assume that there is a conflict in required extensions but I'm not sure. On checking troubleshooting on Plotly https://plotly.com/python/troubleshooting/ , they advise to remove extensions and install them again. But I found that there is additional extension that came with Jupyterlab update called 'jupyterlab-plotly-extension' which is not mentioned by Plotly in their instructions to make it working in JupyterLab https://plotly.com/python/getting-started/#jupyterlab-support-python-35

My question is: which extensions should be installed to make Plotly working in JupyterLab?

  • jupyterlab-plotly as mentioned in Plotly support
  • jupyterlab-plotly-extension that came with JupyterLab
Gonçalo Peres
  • 11,752
  • 3
  • 54
  • 83
Maged
  • 818
  • 1
  • 8
  • 17
  • Just a note for posterity: starting from 5.0 (not yet released at the day of writing) installing plotly for JupyterLab will be much simpler (only one `pip install` and nothing more) - [see here](https://github.com/plotly/plotly.py/issues/3036). – krassowski Jun 21 '21 at 13:56
  • 1
    And 5.0 is now available; use `pip install plotly`. – krassowski Jul 06 '21 at 22:21

4 Answers4

10

You can install plotly using pip or conda:

pip install "plotly>=5" "ipywidgets>=7.6"
# or if using conda
# conda install -c plotly "plotly>=5"
# conda install "ipywidgets>=7.6"

Plotly comes with support for both the Jupyter Notebook and JupyterLab. There is no need to install anything else for JupyterLab 3.0 and newer. The widget package and the renderer package are both included in plotly starting from v5.

For older versions of JupyterLab (1.x and 2.x) you will need a recent Node.js installed and install additional packages; do not run these commands if using newer version of JupyterLab:

pip install "ipywidgets>=7.5"
# renderer support
jupyter labextension install jupyterlab-plotly
# OPTIONAL: Jupyter widgets extension
jupyter labextension install @jupyter-widgets/jupyterlab-manager plotlywidget
krassowski
  • 13,598
  • 4
  • 60
  • 92
  • 1
    Answer is a summary for Plotly support page. My Question is not answered! – Maged Jun 27 '20 at 05:37
  • I updated this answer as it was pinning on an old version of Plotly (potentially introducing security vulnerabilities) and did not mention a new prebuilt extension mechanism. Long story short: no node.js requirement, no build step, nothing; just ensure you are using JupyterLab 3.0+ and `pip install plotly`. – krassowski Jul 23 '21 at 08:23
2

Enter 'jupyter labextension list' in a terminal or command to run the environment status. The example below shows my environment information with 'jupyter lab' running successfully.

xxxxx-no-iMac:~ xxxxx$ jupyter labextension list
JupyterLab v2.1.5
Known labextensions:
   app dir: /Library/Frameworks/Python.framework/Versions/3.6/share/jupyter/lab
        @jupyter-widgets/jupyterlab-manager v2.0.0  enabled  OK
        @jupyterlab/git v0.20.0  enabled  OK
        @lckr/jupyterlab_variableinspector v0.5.0  enabled  OK
        jupyterlab-plotly v1.5.4  enabled  OK
        nbdime-jupyterlab v2.0.0  enabled  OK
        plotlywidget v1.5.4  enabled  OK
r-beginners
  • 31,170
  • 3
  • 14
  • 32
  • not sure what you're saying here, that with the above installed you're able to see plotly output in jupyterlab? Are these the minimal amount required? – baxx Mar 14 '21 at 17:17
  • @baxx My response is to answer how to check if the plotly extension is installed correctly in jupterlab. Please refer to the other answers for installing the extension. – r-beginners Mar 15 '21 at 01:52
1

Assuming that you have installed all the libraries correctly (make sure you have ipywidgets and nodejs installed) and assuming one is using conda, access conda prompt for the environment one is working (the "Server" environment).

Then, you will need to install the extension(s) jupyterlab-plotly (the library nodejs will be required now)

jupyter labextension install jupyterlab-plotly@4.14.3

and plotlywidget [optional] - this one requires nodejs >=10.0.0

jupyter labextension install @jupyter-widgets/jupyterlab-manager plotlywidget@4.14.1

For a more detailed explanation, you may want to read my answer here.

Gonçalo Peres
  • 11,752
  • 3
  • 54
  • 83
0

upyterLab Support (Python 3.5+) For use in JupyterLab, install the jupyterlab and ipywidgets packages using pip...

$ pip install jupyterlab "ipywidgets>=7.5" or conda.

$ conda install jupyterlab "ipywidgets=7.5" Then run the following commands to install the required JupyterLab extensions (note that this will require node to be installed):

JupyterLab renderer support

jupyter labextension install jupyterlab-plotly@4.12.0

OPTIONAL: Jupyter widgets extension

jupyter labextension install @jupyter-widgets/jupyterlab-manager plotlywidget@4.12.0

Refer:

https://plotly.com/python/getting-started/#jupyterlab-support-python-35

Terence Yang
  • 558
  • 6
  • 9