[BUG]: Blank plot in Jupyterlab when plotly is installed in different virtual env from jupyter server

オープン
#5,664 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
52/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
jupyter-notebook, python

調査の方向性

2つの uv 環境と ipython kernel install でインストールしたカーネルを使って空白の図を再現し、デフォルトの fig.show()fig.show(renderer="notebook") を比較します。まず、issue に記載されている Jupyter 関連の挙動と、リンク先の Plotly トラブルシューティングページを確認します。個別の環境でデフォルト表示が動作するか、またはトラブルシューティングのドキュメントで必要なセットアップと回避策が明確に説明されていれば完了です。

索引モデルが issue の本文から書いたものです。

説明

bug P3 size: 3
Description

I am using plotly in an environment managed by JupyterHub. I created a fresh virtual environment (independent from the one managed by JH, which I don't want to modify). I installed plotly in that virtual environment and added it as a kernel to Jupyter by running ipython kernel install in the virtual environment. However, if I open a Jupyter notebook with this kernel and try to create a plot, I get a blank figure. There is no Javascript error in the browser console.

Screenshots/Video
Image
Steps to reproduce

This can be reproduced by creating a clean virtual environment with only Jupyter in it and then another one which contains plotly:

mkdir /tmp/plotly-issue
cd /tmp/plotly-issue

# ~equivalent to the environment managed by JupyterHub
uv init --bare jupyter-env
cd jupyter-env
uv add jupyterlab

cd ..
uv init --bare kernel-env
cd kernel-env
uv add ipykernel plotly nbformat # "Mime type rendering requires nbformat"
uv run ipython kernel install --prefix /tmp/plotly-issue/jupyter-env/.venv/ --name kernel-with-plotly

cd ../jupyter-env
uv run jupyter lab

Then, in jupyterlab, create a new notebook with the kernel kernel-with-plotly and run

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

The figure works correctly if I replace the last line with fig.show(renderer="notebook"). However, the blank figure was very confusing and it took me several hours to find this solution. Additionally, I found a lot of online discussion pointing to this troubleshooting page: https://plotly.com/python/troubleshooting/ which mentions Jupyter / Jupyterlab in the introduction, but there is no section related to Jupyter in the main text. I think this page should be updated with some additional information on Jupyter.

主要言語
Python
スター
18.8k
フォーク
2.8k
平均マージ
16時間 26分
マージ済み PR(30日)
21

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

plotly/plotly.py のほかの issue

plotly/plotly.py の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。