Jupyterlab and Plotly offline: requirejs is not defined
Asked Answered
S

3

13

I installed plot.ly using conda and tried to use it in offline mode on Jupyterlab:

from plotly.offline import init_notebook_mode
init_notebook_mode(connected=True)

The Firefox developer console displays the following error after those statements:

ReferenceError: requirejs is not defined

I tried to manually put require.js into the folder with the notebook and into ...\anaconda3\pkgs\jupyter\nbextensions, it didn't work.

How do I solve this issue? How do I install require.js properly?

Versions:

  • Python 3.6.6
  • Plotly 3.4.2
  • Jupyterlab 0.35.4
  • Windows 10
  • Firefox 64.0.2
  • nodejs 10.15.0
Staysail answered 11/1, 2019 at 14:39 Comment(2)
Hello Khris, did you install Jupyter Lab's plotly extension? Unlike in Jupyter Notebook, plotly plots won't work directly in Jupyter Lab. You need to install his extension: github.com/jupyterlab/jupyter-renderers/tree/master/packages/…Marxist
Hi byouness, I did not, thanks for telling me this. Sadly I can't install it, getting this error: write EPROTO 1172:error:1408F10B:SSL routines:ssl3_get_record:wrong version number:openssl\ssl\record\ssl3_record.c:252:. I'm behind a company proxy, so that might be a reason.Staysail
S
11

Please see Yan Ulms answer: the plotly extension for Jupyter Lab is deprecated


Old answer:

You need to install the plotly extension for Jupyter Lab, as mentioned by @byouness.

A common pitfall in the installation is that you need to have a recent Node.js installation. This might be the cause of your error write EPROTO 1172:error:1408F10B:SSL routines:ssl3_get_record:wrong version number:openssl\ssl\record\ssl3_record.c:252. Re-installing Node.js might be an easy fix.

Your company firewall might indeed be a problem. Because the installation of the extension uses NPM (node.je package manager), you should check Common proxy and networking problems for NPM. You might need to install the extension manually, by following the installation instructions for developers.

I definitely agree that the process is much more difficult than it should be. Installing it at my company was also a struggle. Good luck!

Subantarctic answered 20/1, 2019 at 0:45 Comment(7)
Thanks for the answer. I managed to configure the proxies but I'm still getting the wrong version error. The requirements say node.js > 5 and I have 10.15.0, so this makes no sense. I'll ask that question on their github.Staysail
Hello Khris. Great! If the only error you have is linked to node.js, then try using a node.js version previous to 10 (v8.9.3 for example). I believe there might be some issues with versions 10 and higher depending on the JupyterLab and plotly extension versions you're installing: github.com/jupyterlab/jupyterlab/issues/4986Marxist
Many thanks for finding this, I will try with another version.Staysail
@Marxist I did install v8.15.0 and now I'm getting a different error: request to https://registry.npmjs.org/@jupyterlab%2fplotly-extension failed, reason: write EPROTO 101057795:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol:openssl\ssl\s23_clnt.c:827:. Been looking through some threads like github.com/jspm/github/issues/59 and #15421550 and set strict-ssl to false, but that didn't solve it. Probably an issue with the company proxy server.Staysail
Too bad. I unfortunately can't help with this. I hope @Subantarctic who did a similar installation behind a company proxy wll be able to help!Marxist
Sorry no, this is beyond my knowledge and experience... Thinking out of the box: is it possible to take the computer/laptop out of the firewall zone (e.g. use your phone as a hotspot)? Another exotic idea, is to do the install on another computer, and copy the installation via a memory stick.Subantarctic
at the moment extension link mentioned returns 404Knickknack
L
3

The JupyterLab readme on GitHub says that the @jupyterlab/plotly-extension is being deprecated. Please use the Plotly-supported jupyterlab-plotly. See the plotly.py README for more info.

Lancaster answered 10/10, 2019 at 7:47 Comment(0)
T
0
import plotly.io as pio
pio.renderers.default='iframe'

This worked for me as suggested by an answer here https://github.com/plotly/plotly_express/issues/38#issuecomment-826602624

Topeka answered 28/3 at 10:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.