quarto-dev / quarto-dev/quarto-cli

Embedding cell with Plotly plot fails to render when embedding cell from another document

Open
#10,808 0 comments 1 reaction 1 assignee View on GitHub

@cscheid is already working on this.

Since Sep 16, 2024.

bug plotly
Dominant language
JavaScript
Stars
6k
Forks
458
Avg merge
1d 9h
Merged PRs (30d)
41

Description

Bug description

When embedding a cell from another document, which contains a Plotly plot, in a Qmd file everything works fine. However, when embedding another cell from another document later in the same Qmd file, the Plotly plot fails to render.

The browser outputs:

Failed to load resource: net::ERR_FILE_NOT_FOUND
require.min.js:1  Uncaught Error: Script error for "plotly"
https://requirejs.org/docs/errors.html#scripterror
    at makeError (require.min.js:1:1795)
    at HTMLScriptElement.onScriptError (require.min.js:1:17084)
Steps to reproduce

Reproduce using the following files

doc.qmd

# Plot

{{< embed plot.ipynb#plot >}}

# Table

{{< embed table.ipynb#table >}}

plot.ipynb

#| label: plot
import plotly.express as px
fig = px.scatter(x=[0, 1, 2, 3, 4], y=[0, 1, 4, 9, 16])
fig.show()

table.ipynb

#| label: table

from great_tables import GT
import pandas as pd

GT(pd.DataFrame(dict(a=[1,2,3],b=[1,2,3])))

When modifying doc.qmd like so:
doc.qmd

# Plot

{{< embed plot.ipynb#plot >}}

# Table

no table

the plot will render.

Expected behavior

The Plotly plot should render irrespectively of other included cells.

Actual behavior

The browser console outputs:

Failed to load resource: net::ERR_FILE_NOT_FOUND
require.min.js:1  Uncaught Error: Script error for "plotly"
https://requirejs.org/docs/errors.html#scripterror
    at makeError (require.min.js:1:1795)
    at HTMLScriptElement.onScriptError (require.min.js:1:17084)

and no plot renders.

Your environment

WSL Ubuntu

Quarto check output
'Quarto 1.5.55
[✓] Checking versions of quarto binary dependencies...
      Pandoc version 3.2.0: OK
      Dart Sass version 1.70.0: OK
      Deno version 1.41.0: OK
      Typst version 0.11.0: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
      Version: 1.5.55
      Path: /opt/quarto/bin

[✓] Checking tools....................OK
      TinyTeX: (not installed)
      Chromium: (not installed)

[✓] Checking LaTeX....................OK
      Tex:  (not detected)

[✓] Checking basic markdown render....OK

[✓] Checking Python 3 installation....OK
      Version: 3.10.12
      Path: /home/chirche/Documents/test_quarto/.venv/bin/python
      Jupyter: 5.7.2
      Kernels: python3, sparkrkernel, sparkkernel, pysparkkernel

(|) Checking Jupyter engine render....Traceback (most recent call last):
  File "/opt/quarto/share/jupyter/jupyter.py", line 21, in <module>
    from notebook import notebook_execute, RestartKernel
  File "/opt/quarto/share/jupyter/notebook.py", line 15, in <module>
    from yaml import safe_load as parse_string
ModuleNotFoundError: No module named 'yaml'
[✓] Checking Jupyter engine render....OK

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.