SandboxError
e2b.exceptions.SandboxError
Stack trace
Traceback (most recent call last):
File "install.py", line 42, in <module>
e2b.install_package('some-package') # triggers sandbox error
File "/usr/local/lib/python3.9/site-packages/e2b/__init__.py", line 88, in install_package
raise SandboxError('Package installation blocked by sandbox restrictions')
e2b.exceptions.SandboxError: Package installation blocked by sandbox restrictions Why it happens
E2B runs package installations inside a sandboxed environment to ensure security and isolation. When the sandbox restricts system calls or network access needed for installation, the process fails with a SandboxError. This often happens in restricted CI/CD pipelines or containerized environments without proper permissions.
Detection
Monitor logs for SandboxError exceptions during package install calls and check for denied system calls or network access in sandbox audit logs before the failure.
Causes & fixes
Sandbox environment blocks network access required to download packages
Configure the sandbox to allow outbound network access or pre-cache packages in a local repository accessible inside the sandbox.
Sandbox restricts file system write permissions needed for package installation
Adjust sandbox policies to grant write permissions to the directories where packages are installed.
Sandbox disallows execution of subprocesses needed during package install scripts
Modify sandbox settings to permit subprocess execution or use pre-built wheels that do not require build steps.
Code: broken vs fixed
import e2b
# This line triggers SandboxError due to restricted sandbox
e2b.install_package('requests') # triggers sandbox error import os
import e2b
# Set environment variable to disable sandbox or configure permissions
os.environ['E2B_SANDBOX_DISABLE'] = '1' # disables sandbox for install
# Now install works without sandbox blocking
e2b.install_package('requests')
print('Package installed successfully') Workaround
Catch SandboxError during install, then manually download and install packages outside the sandbox environment or use pre-installed dependencies.
Prevention
Design deployment environments with sandbox policies that explicitly allow necessary network, file system, and subprocess permissions for E2B package installs.