[BUG]: Blank plot in Jupyterlab when plotly is installed in different virtual env from jupyter server
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 18.8k
- Forks
- 2.8k
- Avg merge
- 16h 26m
- Merged PRs (30d)
- 21
Description
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
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the blank figure using the two uv environments and the kernel installed with ipython kernel install, then compare the default fig.show() with fig.show(renderer="notebook"). Start with the Jupyter-related behavior described in the issue and the linked Plotly troubleshooting page. Done means the default display works across the separate environments, or the troubleshooting documentation clearly explains the required setup and workaround.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- jupyter-notebook, python
- Domain
- data-visualization, documentation
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100