Use this option if don’t know beforehand what packages you need in the sandbox. You can install packages with the package manager of your choice.
The packages installed during the runtime are available only in the running sandbox instance.
When you start a new sandbox instance, the packages are not be available.
import { Sandbox } from '@e2b/code-interpreter'const sbx = await Sandbox.create()sbx.commands.run('pip install cowsay') // This will install the cowsay packagesbx.runCode(` import cowsay cowsay.cow("Hello, world!")`)
from e2b_code_interpreter import Sandboxsbx = Sandbox.create()sbx.commands.run("pip install cowsay") # This will install the cowsay packagesbx.run_code(""" import cowsay cowsay.cow("Hello, world!")""")
import { Sandbox } from '@e2b/code-interpreter'const sbx = await Sandbox.create()sbx.commands.run('npm install cowsay') // This will install the cowsay packagesbx.runCode(` const cowsay = require('cowsay') console.log(cowsay.say({ text: 'Hello, world!' }))`, { language: 'javascript' })
from e2b_code_interpreter import Sandboxsbx = Sandbox.create()sbx.commands.run("npm install cowsay") # This will install the cowsay packagesbx.run_code(""" import { say } from 'cowsay' console.log(say('Hello, world!'))""", language="javascript")
3. Install packages with package manager of your choice
Since E2B Sandboxes are Debian based machines, you can use any package manager supported by Debian.
You just need to make sure that the package manager is already installed in the sandbox.For example, to install curl and git, you can use the following commands: