To build the official code-interpreter-v1 template from this repo, use
build_prod.py. This is the script CI and releases run.
- Install the build dependencies:
pip install -r requirements-dev.txt
- Provide your credentials in
.env:
E2B_API_KEY=e2b_***
- Build the template:
python build_prod.py
Set SKIP_CACHE=true to force a clean rebuild that ignores the layer cache:
SKIP_CACHE=true python build_prod.py
If you want to customize the Code Interpreter sandbox (e.g.: add a preinstalled package) you can do that by creating a custom sandbox template.
- Install E2B SDK
pip install e2b dotenv
- Create a custom sandbox template:
template.py
from e2b import Template
template = Template().from_template("code-interpreter-v1")- Create a build script:
build.py
from dotenv import load_dotenv
from .template import template
from e2b import Template, default_build_logger
load_dotenv()
Template.build(
template,
alias="code-interpreter-custom",
cpu_count=2,
memory_mb=2048,
on_build_logs=default_build_logger(),
)- Set your environment variables in a
.envfile (loaded byload_dotenv()):
E2B_API_KEY=e2b_***
- Build the template:
python build.py
- Use the custom template:
from e2b import Sandbox
sbx = Sandbox.create(template="code-interpreter-custom")
execution = sbx.run_code("print('Hello, World!')")
print(execution.logs.stdout)The template runs Jupyter and the code-interpreter server as systemd
services (systemd/jupyter.service, systemd/code-interpreter.service). This is
the path CI and production use — note it is different from make start-template-server, which runs the Docker start-up.sh path. The two can
diverge, so a server that boots fine under Docker may still fail under systemd.
When a build fails its readiness check (Waiting for template to be ready ... timed out), the real cause is in the service journals. To see them:
make debug-template
This builds a debug template (gated on a fixed timeout instead of /health, so
it finalizes even while the server is crash-looping), spawns a sandbox, and
prints systemctl status + the full journalctl for both services. It needs
template/.env with your E2B_API_KEY and the deps from requirements-dev.txt.
The debug build also applies a systemd drop-in that routes Jupyter's stdout to
the journal (make_template(debug=True)). Production builds keep
StandardOutput=null, so Jupyter's request/error logs are only captured in the
debug template.
Inside a running sandbox you can also inspect things directly:
journalctl -u jupyter -u code-interpreter
systemctl status code-interpreter