{"id":18,"library":"e2b-code-interpreter","title":"E2B Code Interpreter","description":"Secure cloud sandboxes for executing AI-generated code. Two packages: e2b-code-interpreter (Jupyter/stateful code execution) and e2b (core sandbox SDK). v0.x is fully deprecated — all versions below 1.0 show deprecation warnings and the API is incompatible with v1.x.","status":"active","version":"2.4.1","language":"python","source_language":"en","source_url":"https://github.com/e2b-dev/code-interpreter","tags":["sandbox","code-execution","agents","python","jupyter","cloud"],"install":[{"cmd":"pip install e2b-code-interpreter","lang":"bash","label":"Python (code interpreter, recommended)"},{"cmd":"pip install e2b","lang":"bash","label":"Python (core sandbox SDK)"},{"cmd":"npm install @e2b/code-interpreter","lang":"bash","label":"Node.js"}],"dependencies":[{"reason":"Core sandbox SDK. e2b-code-interpreter depends on it.","package":"e2b","optional":false},{"reason":"HTTP client used internally by the SDK.","package":"httpx","optional":false}],"imports":[{"note":"CodeInterpreter class was the v0.x entry point. Removed in v1.0. All v0.x code using CodeInterpreter() breaks.","wrong":"from e2b_code_interpreter import CodeInterpreter","symbol":"Sandbox","correct":"from e2b_code_interpreter import Sandbox"},{"note":"Use e2b.Sandbox for general-purpose sandboxes without Jupyter kernel. Use e2b_code_interpreter.Sandbox for stateful code execution with output capture.","wrong":"from e2b_code_interpreter import Sandbox","symbol":"Sandbox (core)","correct":"from e2b import Sandbox"}],"quickstart":{"code":"from e2b_code_interpreter import Sandbox\n\nwith Sandbox() as sandbox:\n    sandbox.run_code(\"x = 1\")\n    execution = sandbox.run_code(\"x += 1; x\")\n    print(execution.text)  # outputs 2","lang":"python","description":"Stateful code execution in a secure cloud sandbox. Requires E2B_API_KEY environment variable."},"warnings":[{"fix":"Replace CodeInterpreter() with Sandbox(). Use context manager: with Sandbox() as sandbox:","message":"CodeInterpreter class removed in v1.0. All v0.x code using CodeInterpreter() or from e2b_code_interpreter import CodeInterpreter fails with ImportError.","severity":"breaking","affected_versions":"< 1.0.0"},{"fix":"Pass cwd per command call instead of at sandbox instantiation.","message":"Global cwd option removed from Sandbox constructor in v1.0. Setting cwd at sandbox creation no longer works.","severity":"breaking","affected_versions":"< 1.0.0"},{"fix":"Review and rewrite any code consuming Sandbox.list() output against v1.x docs.","message":"Sandbox.list() output structure changed in v1.0. Code parsing the old list format breaks silently or raises KeyError.","severity":"breaking","affected_versions":"< 1.0.0"},{"fix":"pip install e2b-code-interpreter>=1.0.0 and follow migration guide at e2b.dev/docs/quickstart/migrating-from-v0","message":"e2b package (core SDK) v0.x is fully deprecated. All PyPI releases below 1.0 display deprecation warnings at import time.","severity":"deprecated","affected_versions":"e2b < 1.0.0"},{"fix":"Use context managers (with Sandbox() as sb:) to ensure sandboxes are closed after use. Explicitly call sandbox.close() in non-context-manager usage.","message":"Sandboxes are billed by runtime duration, not by number of calls. Long-running agents with persistent sandboxes accumulate cost even when idle.","severity":"gotcha","affected_versions":"all"},{"fix":"Check execution.text is not None before use. Also check execution.error for runtime errors in executed code.","message":"execution.text is None if the code produces no output. Accessing .text without checking causes NoneType errors downstream.","severity":"gotcha","affected_versions":"all"}],"env_vars":{"required":[{"name":"E2B_API_KEY","note":"Required for all sandbox operations. Get from e2b.dev/dashboard."}]},"last_verified":"2026-05-11T19:01:39.866Z","next_check":"2026-04-01T00:00:00.000Z","problems":[{"fix":"Replace `from e2b_code_interpreter import CodeInterpreter` with `from e2b_code_interpreter import Sandbox` and use `Sandbox.create()` to initialize the sandbox.","cause":"The `CodeInterpreter` class has been deprecated or removed in recent versions of the `e2b-code-interpreter` SDK, with `Sandbox` becoming the primary entry point for code execution.","error":"ImportError: cannot import name 'CodeInterpreter' from 'e2b_code_interpreter'"},{"fix":"Ensure both the core `e2b` package and the `e2b-code-interpreter` package are installed by running `pip install e2b e2b-code-interpreter`.","cause":"This error occurs when a component of your application (often an older dependency or an integration with another library) expects the core `e2b` package to be installed, but it's either missing or a newer project primarily uses `e2b-code-interpreter` without explicitly installing `e2b`.","error":"ImportError: Unable to import e2b, please install with `pip install e2b`."},{"fix":"Obtain a valid E2B API key from e2b.dev and set it as an environment variable named `E2B_API_KEY` (e.g., `export E2B_API_KEY=e2b_YOUR_KEY`). Alternatively, pass it directly when creating the sandbox, like `Sandbox.create(api_key='e2b_YOUR_KEY')`.","cause":"The E2B SDK could not authenticate due to a missing, incorrect, or expired API key. The API key must be provided either as an environment variable or directly in the code.","error":"AuthenticationError: Unauthorized, please check your credentials. - Invalid API key"},{"fix":"Check the E2B sandbox logs for more specific internal errors. If the issue occurs during package installation (e.g., Pandas), ensure your custom template or Dockerfile is correctly configured and that the sandbox has sufficient resources. If the problem persists with standard templates, contact E2B support.","cause":"This error indicates an unexpected termination of the connection between your application and the E2B sandbox. It can be caused by internal sandbox issues, such as a process crashing, resource exhaustion, or problems during library installation within the sandbox environment.","error":"Peer closed connection without sending complete message body"},{"fix":"When creating custom templates, ensure you inherit from `code-interpreter-v1` or, if building from a Docker image, explicitly set the start command: `.setStartCmd('sudo /root/.jupyter/start-up.sh')` with `e2bdev/code-interpreter:latest` as the base image. Additionally, consider increasing the sandbox's timeout parameter.","cause":"This error typically occurs when using custom sandbox templates where the default start command for the code interpreter is not correctly specified, or a non-code-interpreter base image is used without the necessary setup. It can also signify a sandbox timeout.","error":"{\"sandboxId\":\"...\",\"message\":\"The sandbox is running but port is not open\",\"port\":49999,\"code\":502}"}],"ecosystem":"pypi","meta_description":null,"install_score":100,"install_tag":"verified","quickstart_score":0,"quickstart_tag":"stale","pypi_latest":null,"install_checks":{"last_tested":"2026-05-11","tag":"verified","tag_description":"installs cleanly on critical runtimes, fast import, recently tested","results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":4.63,"mem_mb":24.3,"disk_size":"41.7M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":6.08,"mem_mb":22.6,"disk_size":"43M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":5.57,"mem_mb":26.6,"disk_size":"46.5M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":5,"mem_mb":24.8,"disk_size":"47M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":5.63,"mem_mb":26.5,"disk_size":"37.8M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":5.89,"mem_mb":24.2,"disk_size":"39M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":5.75,"mem_mb":27.1,"disk_size":"37.5M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":5.3,"mem_mb":25.3,"disk_size":"38M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.8,"mem_mb":22.1,"disk_size":"39.8M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":2.54,"mem_mb":19.5,"disk_size":"41M"}]},"quickstart_checks":{"last_tested":"2026-05-11","tag":"stale","tag_description":"widespread failures or data too old to trust","results":[{"runtime":"python:3.10-alpine","exit_code":1},{"runtime":"python:3.10-slim","exit_code":1},{"runtime":"python:3.11-alpine","exit_code":1},{"runtime":"python:3.11-slim","exit_code":1},{"runtime":"python:3.12-alpine","exit_code":1},{"runtime":"python:3.12-slim","exit_code":1},{"runtime":"python:3.13-alpine","exit_code":1},{"runtime":"python:3.13-slim","exit_code":1},{"runtime":"python:3.9-alpine","exit_code":1},{"runtime":"python:3.9-slim","exit_code":1}]}}