Skip to main content

Code Interpreter

Built on top of e2b with added support for multi-language code execution (Python, JavaScript, R, Java, Bash), pre-installed data science libraries, and visualization capabilities.
Includes all features from e2b plus specialized code execution methods and pre-configured environment.

Installation

pip install e2b-code-interpreter

Quick Start

from e2b_code_interpreter import Sandbox

# Create code interpreter
sbx = Sandbox()

# Execute Python with visualization
execution = sbx.run_code("""
import matplotlib.pyplot as plt
plt.plot([1, 2, 3, 4])
plt.ylabel('some numbers')
plt.savefig('chart.png')
""")

# Access results
for result in execution.results:
    print(result)

sbx.close()

Supported Languages

Python

Full Python support with data science libraries

JavaScript

Node.js runtime for JavaScript execution

R

Statistical computing with R

Java

Java code execution

Bash

Shell scripts and commands

Pre-installed Libraries

The code interpreter comes with popular data science and visualization libraries:
  • Data Analysis: pandas, numpy, scipy
  • Visualization: matplotlib, seaborn, plotly
  • Machine Learning: scikit-learn
  • And many more…
View full list →
  • Node.js built-in modules
  • Popular npm packages (install as needed)

Features

Code Execution Results

Access execution results including stdout, stderr, charts, and data:
execution = sbx.run_code("print('Hello'); 2 + 2")

for result in execution.results:
    if result.type == "stdout":
        print(result.text)
    elif result.type == "result":
        print(result.data)

Chart Generation

Create and retrieve visualizations:
execution = sbx.run_code("""
import matplotlib.pyplot as plt
import numpy as np

x = np.linspace(0, 10, 100)
plt.plot(x, np.sin(x))
plt.title('Sine Wave')
plt.savefig('plot.png')
""")

# Charts are available in results
for result in execution.results:
    if result.type == "image":
        print(f"Chart saved: {result.url}")

Use Cases

AI Data Analysis

Build AI agents that analyze datasets and create visualizations

Code Execution Environments

Create Jupyter-like environments for interactive coding

Automated Reporting

Generate reports with code, analysis, and charts

Educational Platforms

Run student code safely in sandboxed environments