Skip to main content
Python

Installing Packages

Install Python packages inside an Agent OS Exec runtime.

install() runs python -m pip install inside the VM. Installed packages stay available to later Python processes for the lifetime of that runtime.

import { PythonRuntime } from "@rivet-dev/agentos/python";

const runtime = await PythonRuntime.create();
try {
	const installed = await runtime.install(["requests"], { upgrade: true });
	if (!installed.success) throw new Error(installed.stderr);

	const result = await runtime.execute(`
import requests
print(requests.__version__)
	`);
	if (!result.success) throw new Error(result.stderr);
} finally {
	await runtime.dispose();
}

Package downloads obey the VM’s network policy and resource limits. Configure those once in PythonRuntime.create(); see the general AgentOS Software, Networking, and Resource Limits docs for the underlying behavior.

The install options support upgrade, indexUrl, extraIndexUrls, and the same timeout, cancellation, environment, and streaming options as execution.