e2b-dev / e2b-dev/E2B

Python HTML Chart Output Fragmented in Sandbox while R Charts Display Correctly

Open
#670 4 comments 0 reactions 1 assignee View on GitHub

@jakubno is already working on this.

Since May 10, 2025.

bug Code Interpreter
Dominant language
Python
Stars
13.9k
Forks
1k
Avg merge
1d 20h
Merged PRs (30d)
70

Description

Describe the bug
HTML output from Python visualization libraries (Plotly/Bokeh) in the sandbox is fragmented into multiple objects, resulting in incomplete rendering. This issue appears specific to Python HTML-generating chart libraries, as the same charts created with R display correctly with complete HTML output.

To Reproduce

const code = `
    import plotly.express as px
    import pandas as pd
    
    data = {
        'Month': ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun'],
        'Sales': [20, 35, 30, 40, 55, 60]
    }
    
    df = pd.DataFrame(data)
    
    fig = px.line(df, x='Month', y='Sales', title='Monthly Sales')
    
    fig.update_layout(
        xaxis_title='Month',
        yaxis_title='Sales ($1000s)',
        template='plotly_white'
    )
    
    fig.show()
`
await sandbox.runCode(code, {
    language: 'python',
    onResult: async result => {
        if ('html' in result && result.html) {
          // Truncate the output for demo purposes
          console.log('HTML Output: ', result.html.substring(0, 200))
    }
})

Expected output: Complete HTML in a single object (as seen with R charts)

Actual output:

HTML Output: <script type="text/javascript"> window.PlotlyConfig = {MathJaxConfig: 'local'}; if (window.MathJax && window.MathJax.Hub && window.MathJax.Hub.Config) {window.MathJax.Hub.Confi
HTML Output:  <div><div id="0bd7d700-2c9b-441c-84b4-084dce8b1bea" class="plotly-graph-div" style="height:525px; width:100%;"></div><script type="text/javascript">

Additional context:
The same visualization created with R in the sandbox produces a single complete HTML output without fragmentation.

"e2b": "^1.2.0-beta.0"
"@e2b/cli": "^1.3.2"
"@e2b/code-interpreter": "^1.2.0-beta.1"

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.