Skip to main content
marimo provides built-in package management using PEP 723 inline script metadata. Dependencies are declared directly in your notebook and can be automatically installed in isolated environments.

PEP 723 Script Metadata

marimo notebooks can include dependency information at the top of the file:
notebook.py
The # /// markers define a PEP 723 metadata block. This is a standard format supported by tools like uv.

Auto-Install with uv

When using --sandbox mode, marimo automatically manages dependencies using uv.

Installing uv

First, install uv:

Running in Sandbox Mode

When you open a notebook with dependencies:
  1. marimo detects the PEP 723 metadata
  2. Prompts: “Run in a sandboxed venv?”
  3. Creates an isolated environment with uv
  4. Installs all dependencies automatically
  5. Runs the notebook in that environment
Use marimo -y edit notebook.py to auto-accept the sandbox prompt.
For directories:
  • Each notebook has its own isolated venv
  • Dependencies are per-notebook, not shared
  • Requires pyzmq for IPC communication:

Managing Dependencies

Adding Packages

marimo provides a UI for adding packages, or you can use uv directly:
This updates the metadata block:

Version Constraints

Specify version requirements using standard pip syntax:

Python Version

Specify required Python version:
marimo will use this version when creating the sandbox environment.

Package Sources

Custom Index URLs

Use private PyPI servers or mirrors:

Extra Index URLs

Combine multiple package sources:

Named Indexes

Use named indexes for better control:

Auto-Install on Import

When running without --sandbox, marimo can detect missing packages:
Auto-install without sandbox installs packages globally. Use --sandbox for isolated environments.

Serializing Dependencies

Export Requirements

Generate a requirements.txt from script metadata:
Creates:
requirements.txt

Lock Files

For reproducible environments, use lock files:

Virtual Environments

Manual Virtual Environments

You can still use traditional virtual environments:

Sandbox vs. Manual venvs

Environment Variables

Metadata Management

Control when marimo manages metadata:
When enabled, marimo automatically:
  • Adds marimo to dependencies if missing
  • Updates requires-python based on current Python version
  • Keeps metadata in sync with your environment

Common Workflows

Troubleshooting

Problem: marimo edit --sandbox fails with “uv not found”Solution: Install uv:
Problem: marimo edit ./dir --sandbox failsSolution: Install sandbox extras:
Problem: Dependency resolution errorsSolution:
Problem: First --sandbox run is slowSolution: This is normal - uv is creating a venv and installing packages. Subsequent runs use cached environments.Speed it up:

Best Practices

1

Pin important versions

2

Document package choices

3

Keep dependencies minimal

Only include packages you actually import:
4

Test in sandbox mode

Comparison with Other Tools

Advanced Configuration

Editable Installs

For development, install packages in editable mode:
Updates metadata:

Environment-Specific Dependencies

Use environment markers:

Next Steps

Creating Notebooks

Learn notebook structure and cells

Running Notebooks

Explore execution modes