【问题标题】:What is Right extension for Plotly in JupyterLab?JupyterLab 中 Plotly 的正确扩展是什么?
【发布时间】:2020-06-27 01:29:48
【问题描述】:

Plotly 在 Jupyterlab 中不起作用。我认为所需的扩展存在冲突,但我不确定。 在 Plotly https://plotly.com/python/troubleshooting/ 检查故障排除时,他们建议删除扩展并重新安装。 但我发现 Jupyterlab 更新附带了一个名为“jupyterlab-plotly-extension”的附加扩展 Plotly 在他们的说明中没有提到让它在 JupyterLab https://plotly.com/python/getting-started/#jupyterlab-support-python-35

中工作

我的问题是:应该安装哪些扩展才能使 Plotly 在 JupyterLab 中工作?

  • 在 Plotly 支持中提到的 jupyterlab-plotly
  • JupyterLab 附带的 jupyterlab-plotly-extension

【问题讨论】:

  • 只是给后人的注意事项:从 5.0 开始(在撰写本文时尚未发布)为 JupyterLab 安装 plotly 将更加简单(只有一个 pip install 仅此而已) - see here
  • 现在可以使用 5.0 了;使用pip install plotly

标签: python plotly jupyter libraries jupyter-lab


【解决方案1】:

您可以使用 pip 或 conda 进行 plotly 安装:

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

Plotly 支持 Jupyter Notebook 和 JupyterLab。对于 JupyterLab 3.0 及更高版本,无需安装任何其他内容。从 v5 开始,小部件包和渲染器包都包含在 plotly 中。

对于旧版本的 JupyterLab(1.x 和 2.x),您需要安装最新的 Node.js 并安装其他软件包;如果使用较新版本的 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

【讨论】:

  • Answer 是 Plotly 支持页面的摘要。我的问题没有得到解答!
  • 我更新了这个答案,因为它固定在旧版本的 Plotly 上(可能会引入安全漏洞)并且没有提到新的预建扩展机制。长话短说:没有 node.js 要求,没有构建步骤,什么都没有;只需确保您使用的是 JupyterLab 3.0+ 和 pip install plotly
【解决方案2】:

在终端或命令中输入“jupyter labextension list”以运行环境状态。下面的示例显示了我的环境信息,“jupyter lab”成功运行。

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

【讨论】:

  • 不确定你在说什么,安装了上面的东西后你可以在 jupyterlab 中看到 plotly 输出吗?这些是最低要求吗?
  • @baxx 我的回答是回答如何检查在 jupterlab 中是否正确安装了 plotly 扩展。安装扩展请参考其他答案。
【解决方案3】:

upyterLab 支持 (Python 3.5+) 要在 JupyterLab 中使用,请使用 pip 安装 jupyterlab 和 ipywidgets 包...

$ pip install jupyterlab "ipywidgets>=7.5" 或康达。

$ conda install jupyterlab "ipywidgets=7.5" 然后运行以下命令安装所需的 JupyterLab 扩展(注意这将需要安装节点):

JupyterLab 渲染器支持

jupyter labextension 安装 jupyterlab-plotly@4.12.0

可选:Jupyter 小部件扩展

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

参考:

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

【讨论】:

    【解决方案4】:

    假设您已正确安装所有库(确保已安装 ipywidgetsnodejs)并假设其中一个正在使用 conda,请访问 conda prompt 以获取正在运行的环境(“服务器”环境)。

    然后,您需要安装扩展程序 jupyterlab-plotly(现在需要库 nodejs

    jupyter labextension install jupyterlab-plotly@4.14.3
    

    plotlywidget [可选] - 这个需要nodejs >=10.0.0

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

    如需更详细的解释,您可能需要阅读my answer here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-07-27
      • 2020-08-18
      • 2012-01-03
      • 1970-01-01
      • 2020-10-17
      • 1970-01-01
      • 2020-02-13
      相关资源
      最近更新 更多