Jupyterlab和Plotly离线:未定义requirejs

时间:2019-01-11 14:39:29

标签: python requirejs plotly jupyter-lab

我使用conda安装plot.ly,并尝试在Jupyterlab上以离线模式使用它:

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

在这些语句之后,Firefox开发者控制台显示以下错误:

ReferenceError: requirejs is not defined

我试图手动将require.js放在笔记本的文件夹中,再放入...\anaconda3\pkgs\jupyter\nbextensions,这没用。

如何解决此问题?如何正确安装require.js?

版本:

  • Python 3.6.6
  • 密谋3.4.2
  • Jupyterlab 0.35.4
  • Windows 10
  • Firefox 64.0.2
  • nodejs 10.15.0

2 个答案:

答案 0 :(得分:7)

您需要安装plotly extension for Jupyter Lab,如@byouness所述。

安装中的一个常见陷阱是您需要最近安装Node.js。这可能是导致您的错误write EPROTO 1172:error:1408F10B:SSL routines:ssl3_get_record:wrong version number:openssl\ssl\record\ssl3_record.c:252的原因。重新安装Node.js可能很容易。

您公司的防火墙确实可能是一个问题。由于扩展的安装使用NPM(node.je程序包管理器),因此应检查Common proxy and networking problems中是否存在NPM。您可能需要按照installation instructions for developers进行手动安装扩展。

我绝对同意,该过程比原本应该困难得多。在我公司安装它也是一个挣扎。祝你好运!

答案 1 :(得分:1)

GitHub上的JupyterLab自述文件指出,@jupyterlab/plotly-extension已被弃用。请使用Plotly支持的jupyterlab-plotly 。有关更多信息,请参见plotly.py README