Black Lives Matter. Please consider donating to Black Girls Code today.

Plotlywidget nbextension error

When I use FigureWidget in jupyter notebooks, no plot is shown when the cell is executed.


and I get the following error in my console
error

However, when I call using something like iplot(f), then the plot displays:

I think this is occurring because my plotlywidget nbextension is not installed correctly, so I did
jupyter nbextension list
ext

I think this means that plotlywidget was not installed. I also have up-to-date versions of packages since I have followed these threads:

*Error Displaying FigureWidget
*Generating plots using FigureWidget in a for loop

Is there any way I could manually download the source for plotly widget to install it so the extension will work? Long story short, I run into permission errors (only allowed to use conda and pip install for approved packages, later versions I have to python setup.py install from source) so when I do ‘jupyter nbextension install plotlywidget’ or some variant thereof I run into problems.

Hi @nicolascage,

Yeah, it looks like a problem with the extension installation. Unlike the classic notebook, the installation of JupyterLab extensions requires access to the public npm repository (https://www.npmjs.com/), even when installing the extensions from source.

Also, to get plotlywidget to work, you need a working install of the @jupyter-widgets/jupyterlab-manager extension (this extension supports the built-in ipywidgets).

If you don’t have npm access, you’ll need to look into offline installation of JupyterLab extensions. This is not a very smooth process at the moment, here’s the best info I know of right now https://github.com/jupyterlab/jupyterlab/issues/4494.

Though it doesn’t help you today, we do have plans to build and release a conda package that will bundle all of the plotly related JupyterLab extensions. It sounds like that would be helpful in your situation, so keep an eye out for that :slightly_smiling_face:

-Jon

Hi @jmmease! Thanks for the quick and detailed response. As a follow up, are you saying that to get this to work for Jupyter Notebook, I also have to have a working installation of the Jupyter Lab extension? I’m currently not using Lab and just trying to get it to display for Notebook. I’ll take a look at that link and post updates if I can get it to work.

Oh sorry, I misunderstood your situation. No, if you’re using the classic notebook none of that JupyterLab info is necessary :slightly_smiling_face:

I’d recommend double checking that you have "notebook>=5.3" and "ipywidgets>=7.2" installed using either conda or pip (not both).

If that doesn’t help, could you include your full output of:

  • pip list
  • jupyter nbextension list
  • conda list

-Jon

Hi Jon,

Sorry for not responding quickly. The good news is that I managed to get FigureWidget to work and display properly! What I ended up doing was doing a fresh environment for Python 3.7 with the default packages from Anaconda3 on a separate laptop. I then only needed to conda install plotly and then everything worked on that laptop when using Jupyter Notebook. I packaged up the environment and did an offline installation on my other computer which allowed me to have an environment with a working FigureWidget functionality. Although I have not yet fully investigated why it was so hard to get FigureWidget to originally work on my main computer, I think it might be a result of using both conda and pip to install packages which like you said, shouldn’t be done.

1 Like