Plotly 图表不会在使用 Zero To JupyterHub (GKE) 安装的 JupyterLab 上呈现

标签 plotly jupyter-lab jupyterhub

我尝试在 JupyterLab 上渲染 Plotly 图表,该图表是通过 GKE 上的 Zero to JupyterHub 安装的。我按照此处的文档进行操作:

https://plotly.com/python/getting-started/

但是,图表仍然无法直接在 JupyterLab 上渲染。我还有什么遗漏的吗?

感谢您的帮助!

最佳答案

找到了答案,您实际上必须在该过程中添加更多步骤。完整内容如下:

  1. plotly 安装 pip install plotly==4.9.0
  2. 安装/升级 Jupyterlab 小部件 pip install jupyterlab "ipywidgets>=7.5"
  3. 安装 jupyterlab 扩展 jupyter labextension install <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="503a2520292435223c31327d203c3f243c2910647e697e60" rel="noreferrer noopener nofollow">[email protected]</a>
  4. 可选jupyter labextension install @jupyter-widgets/jupyterlab-manager <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="84f4e8ebf0e8fdf3ede0e3e1f0c4b0aabdaab4" rel="noreferrer noopener nofollow">[email protected]</a>
  5. 可选,检查已安装的扩展 jupyter labextension list
  6. 刷新 jupyterlab 页面
  7. 通过运行 jupyter lab build 构建镜像

现在您可以打开笔记本并运行一些示例绘图代码:

import plotly.graph_objects as go
fig = go.Figure(data=go.Bar(y=[2, 3, 1]))
fig.show()

您应该看到出现的图表;)

关于Plotly 图表不会在使用 Zero To JupyterHub (GKE) 安装的 JupyterLab 上呈现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63449330/

相关文章:

python-3.x - 更改在 plotly 中悬停在 Choropleth map 上时出现的内容的属性

r - 将鼠标悬停在 R 中时获取点的名称

jupyter-notebook - 将新代码导入 Jupyter Lab

jupyterhub:找不到命令

java.io.IOException : Could not read footer for file FileStatus when trying to read parquet file from Spark cluster from IBM Cloud Object Storage

javascript - 将 Plot.ly 与外部脚本结合使用来绘制图表

python - 一些 Plotly 绘图未在 JupyterLab 中显示

python - 在 Jupyter 中导入 PyCaret 时找不到模块

docker - Kubernetes:为什么我的 NodePort 无法获取外部 ip?

R - plotly 错误对象...未找到