skillfed

e2b-code-interpreter

E2B Code Interpreter - Stateful code execution

e2b-code-interpreter v2.9.1 2.6M downloads/30d#2,963 on PyPI2,377
Permissive license MIT Active released

What it is and what it does

E2B Code Interpreter is a Python SDK that provisions and controls isolated, stateful code execution environments in E2B's cloud infrastructure. It lets you run Python code—typically generated by LLMs or user input—in a sandbox where each execution preserves state from previous runs, so variables and imports persist across calls. You authenticate with an API key, create a sandbox context, and call run_code() to execute snippets; the sandbox returns execution results including stdout and any errors.

The package is designed for AI workflows where you need to safely execute untrusted or dynamically generated code without risking your local system. It abstracts away sandbox provisioning and lifecycle management, exposing a simple context-manager interface. The underlying e2b dependency handles the cloud communication; httpx manages HTTP requests and attrs provides data structures.

Use it for:

  • Execute LLM-generated Python code safely in an AI agent or chatbot without running it locally.
  • Build interactive notebooks or REPLs where code state persists across user inputs in a cloud sandbox.
  • Test or validate user-submitted scripts in a secure, isolated environment before review.
  • Run data analysis or math code from untrusted sources without exposing your system.
  • Prototype multi-step workflows where intermediate results must carry over between code blocks.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Runs AI-generated or arbitrary Python code in isolated cloud sandboxes with state preservation across multiple executions.

Yes, if you need to execute untrusted or AI-generated code safely. The package is actively maintained, has low install friction, uses a permissive license, and provides a clean API for a real security need. Requires an E2B account and API key, and incurs cloud costs; verify pricing and resource limits before committing to production use.

Install

e2b-code-interpreter on PyPI

pip

pip install e2b-code-interpreter

uv

uv add e2b-code-interpreter

poetry

poetry add e2b-code-interpreter

Installing e2b-code-interpreter

Before you install

Low friction install with a pure Python wheel. Active maintenance—last commit 2026-08-13, released 1 day ago. Supports Python 3.10 through 3.13. Depends on three lightweight runtime packages: httpx, attrs, and e2b.

License in practice

MIT license (permissive). You can use, modify, and distribute this package freely in commercial or private projects with minimal restrictions.

Quickstart

pip install e2b-code-interpreter

from e2b_code_interpreter import Sandbox

with Sandbox.create() as sandbox:
    sandbox.run_code("x = 1")
    execution = sandbox.run_code("x+=1; x")
    print(execution.text)

Requires a valid E2B API key set as the E2B_API_KEY environment variable; sign up at e2b.dev to obtain one.

Verify before relying

  • Pricing model and cost per sandbox execution or compute time.
  • Sandbox resource limits (memory, CPU, execution timeout).
  • Supported Python versions inside the sandbox vs. the host interpreter.
  • Data residency and compliance certifications for the cloud infrastructure.

Package facts

License MIT (permissive)
Python support supports the current Python release (<4.0,>=3.10)
Install friction low — pure-Python wheel
Runtime dependencies 3 — httpx, attrs, e2b
Maintenance actively maintained — 1 days since the last release
Last repo commit
First released
Downloads 2,640,566/month — #2,963 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: e2b_code_interpreter-2.9.1-py3-none-any.whl

License :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13

Tags

execute code in sandboxisolated code executionai code interpreterstateful code runnersecure code execution cloudpython sandbox environmentllm code execution
code-executionai-safetysandbox

More Distributed Computing packages