### Complete Marimo App Example Source: https://docs.marimo.io/guides/editor_features/watching?q= A full example demonstrating setup, top-level functions, classes, and running the Marimo app. ```python import marimo app = marimo.App() with app.setup: import numpy as np CONSTANT: int = 1 @app.function def my_function(x: np.ndarray): return np.mean(x) + CONSTANT @app.class_definition class MyClass: ... @app.cell def _(): my_function(np.random.randn(2, 2)) return if __name__ == "__main__": app.run() ``` -------------------------------- ### Correct Setup Cell Initialization Source: https://docs.marimo.io/guides/lint_rules/rules/setup_cell_dependencies This example demonstrates a correctly structured setup cell that initializes its own variables. Other cells can then safely use variables defined in the setup cell. ```python # Setup cell y = 1 # Setup defines its own variables # Cell 1 x = y + 1 # Other cells can use setup variables ``` -------------------------------- ### Create Sandbox Notebook and Add Local Library Source: https://docs.marimo.io/guides/package_management/notebooks_in_projects?q= Create a sandbox notebook within your library project and add the library itself as an editable dependency. This setup is for creating example notebooks that use your library. ```bash # Create a sandbox notebook mkdir examples uv run marimo edit --sandbox examples/quickstart.py # Add your library as editable dependency uv add --script examples/quickstart.py . --editable ``` -------------------------------- ### Create venv and install packages with uv Source: https://docs.marimo.io/guides/package_management/using_uv Use `uv venv` to create a virtual environment and `uv pip` to install packages like numpy and marimo. Then, use `uv run marimo edit` to start the marimo editor. ```console $ uv venv $ uv pip install numpy $ uv pip install marimo $ uv run marimo edit ``` -------------------------------- ### Start Marimo in Sandbox Mode Source: https://docs.marimo.io/guides/package_management/importing_packages?q= Use the `--sandbox` flag to create an isolated, per-notebook virtual environment. Dependencies installed via the editor will be inlined into the notebook file. ```bash marimo edit --sandbox my_notebook.py ``` -------------------------------- ### Install uv and start marimo in a SkyPilot cluster Source: https://docs.marimo.io/guides/deploying/deploying_skypilot?q= Inside the cluster, install uv and then run marimo using uvx with the --sandbox flag for isolated dependencies. Access your notebook via localhost:8080. ```bash pip install uv uvx marimo edit --sandbox demo.py --port 8080 --token-password=supersecret ``` -------------------------------- ### Install marimo with uv Source: https://docs.marimo.io/?q= Installs marimo using uv, a fast Python package installer, and then runs the tutorial introduction. Recommended for faster dependency management. ```bash uv add marimo && uv run marimo tutorial intro ``` -------------------------------- ### Start Marimo Notebook Server Source: https://docs.marimo.io/cli Launches the Marimo notebook server. This command can be used without any arguments to start the server. ```text marimo edit ``` -------------------------------- ### Install marimo with SQL support using uv Source: https://docs.marimo.io/integrations/motherduck?q= Install the marimo package with SQL capabilities using uv. This is an alternative to pip for package installation. ```bash uv add "marimo[sql]" ``` -------------------------------- ### Install kubectl-marimo plugin Source: https://docs.marimo.io/guides/deploying/deploying_kubernetes?q= Install the kubectl-marimo CLI plugin using uv (recommended) or pip. ```bash # With uv (recommended) uv tool install kubectl-marimo # Or with pip pip install kubectl-marimo ``` -------------------------------- ### Populate Marimo Form with Pre-defined Examples Source: https://docs.marimo.io/recipes?q= Pre-populate a form with example data for illustration or to showcase complex inputs. Use `mo.ui.dropdown` to select examples and `mo.md.batch` to map example values to form fields. The form can also be populated from URL query parameters. ```python import marimo as mo ``` ```python examples = mo.ui.dropdown( options={ "ex 1": {"t1": "hello", "t2": "world"}, "ex 2": {"t1": "marimo", "t2": "notebook"}, }, value="ex 1", label="examples", ) ``` ```python form = ( mo.md( """ ### Your form {t1} {t2} """ ) .batch( t1=mo.ui.text(label="enter text", value=examples.value.get("t1", "")), t2=mo.ui.text(label="more text", value=examples.value.get("t2", "")), ) .form( submit_button_label="go" ) ) ``` ```python output = ( " ".join(form.value.values()).upper() if form.value is not None else " ".join(examples.value.values()).upper() ) examples, form, output ``` -------------------------------- ### Run Full BigQuery Example Source: https://docs.marimo.io/integrations/google_cloud_bigquery?q= Execute a full example of using Google Cloud BigQuery with Marimo by running a Python script from a URL. ```bash marimo run https://raw.githubusercontent.com/marimo-team/marimo/main/examples/cloud/gcp/google_cloud_bigquery.py ``` -------------------------------- ### Example Snapshot Filename Source: https://docs.marimo.io/guides/exporting/sessions?q= An example of the generated snapshot filename for a notebook named 'notebook.py'. ```bash __marimo__/session/notebook.py.json ``` -------------------------------- ### Install marimo with pip Source: https://docs.marimo.io/?q= Installs marimo using pip and launches the tutorial introduction. Use this method for standard Python environments. ```bash pip install marimo && marimo tutorial intro ``` -------------------------------- ### Run Full BigQuery Example Source: https://docs.marimo.io/integrations/google_cloud_bigquery Execute a complete marimo example that utilizes Google Cloud BigQuery by running a command in your terminal. ```bash marimo run https://raw.githubusercontent.com/marimo-team/marimo/main/examples/cloud/gcp/google_cloud_bigquery.py ``` -------------------------------- ### Open the Intro Tutorial Source: https://docs.marimo.io/cli?q= Use this command to open the introductory tutorial for marimo. ```bash marimo tutorial intro ``` -------------------------------- ### Open Intro Tutorial Source: https://docs.marimo.io/cli Use this command to open the introductory marimo tutorial. ```text marimo tutorial intro ``` -------------------------------- ### Install pylsp Source: https://docs.marimo.io/guides/editor_features/language_server Install the core Python language server and Ruff integration for Marimo. This provides completions, hover, go-to-definition, and diagnostics. ```bash pip install "marimo[lsp]" ``` ```bash uv add "marimo[lsp]" ``` ```bash conda install -c conda-forge python-lsp-server python-lsp-ruff ``` -------------------------------- ### Create Sandbox Example Notebook and Add Library Source: https://docs.marimo.io/guides/package_management/notebooks_in_projects Commands to create a sandbox notebook within an example directory and add the local library as an editable dependency. ```bash # Create a sandbox notebook mkdir examples uv run marimo edit --sandbox examples/quickstart.py # Add your library as editable dependency uv add --script examples/quickstart.py . --editable ``` -------------------------------- ### Problematic Setup Cell Dependency Source: https://docs.marimo.io/guides/lint_rules/rules/setup_cell_dependencies This example shows a setup cell that incorrectly depends on a variable 'x' defined in another cell. Setup cells must be self-contained or only depend on variables defined within themselves. ```python # Setup cell y = x + 1 # Error: setup depends on other cells # Cell 1 x = 1 ``` -------------------------------- ### Check marimo installation with uv Source: https://docs.marimo.io/getting_started/installation Run this command after installation with uv to verify marimo is working correctly. A tutorial notebook should open in your browser. ```bash uv run marimo tutorial intro ``` -------------------------------- ### Initialize Library Project and Add Marimo Source: https://docs.marimo.io/guides/package_management/notebooks_in_projects?q= Set up a new library project using `uv init --lib` and add Marimo as a development dependency. This is the first step for creating example sandbox notebooks for your library. ```bash # Initialize the project uv init --lib my-library && cd my-library # Add marimo as development dependency uv add --dev marimo ``` -------------------------------- ### start property Source: https://docs.marimo.io/api/inputs/dates?q= Gets the minimum selectable datetime for the datetime picker. ```APIDOC ## start property ### Description Get the minimum selectable datetime. ### Returns - **datetime** - The start datetime, which is either the user-specified minimum datetime or datetime.min if no start datetime was specified. ``` -------------------------------- ### Run Google Sheets Example Source: https://docs.marimo.io/integrations/google_sheets Run a full example of using Google Sheets with marimo by executing a Python script from a URL. ```bash marimo run https://raw.githubusercontent.com/marimo-team/marimo/main/examples/cloud/gcp/google_sheets.py ``` -------------------------------- ### Initialize Project and Add Dependencies Source: https://docs.marimo.io/guides/package_management/notebooks_in_projects Initialize a new project using uv and add marimo and other data science libraries as dependencies. ```bash # Initialize project uv init analysis-project && cd analysis-project # Add marimo as a project dependency uv add marimo pandas scikit-learn # Edit notebooks using project environment uv run marimo edit notebook.py ``` -------------------------------- ### Run Google Sheets Example Source: https://docs.marimo.io/integrations/google_sheets?q= Execute a full example of using Google Sheets with Marimo by running a provided Python script URL. ```bash marimo run https://raw.githubusercontent.com/marimo-team/marimo/main/examples/cloud/gcp/google_sheets.py ``` -------------------------------- ### Initialize a uv Project Source: https://docs.marimo.io/guides/package_management/using_uv?q= Create a new uv project directory named 'hello-world'. This command sets up the project structure and a pyproject.toml file for dependency management. ```bash uv init hello-world cd hello-world ``` -------------------------------- ### Get Minimum Selectable Datetime Source: https://docs.marimo.io/api/inputs/dates Retrieves the minimum selectable datetime from the datetime picker. This will be the user-specified start date or the earliest possible datetime if none was set. ```python start: datetime ``` -------------------------------- ### Run Marimo in Non-Project Environment Source: https://docs.marimo.io/guides/package_management/using_uv?q= Start the Marimo editor within a non-project environment where packages have been installed using 'uv pip'. This allows notebooks to import these packages. ```bash $ uv run marimo edit ``` -------------------------------- ### List Marimo Tutorials Source: https://docs.marimo.io/getting_started/quickstart?q= Use this command to list all available marimo tutorials. ```bash marimo tutorial --help ``` -------------------------------- ### Recommended Tutorial Sequence Source: https://docs.marimo.io/cli?q= Follow this sequence to learn marimo effectively, starting with the intro and progressing through advanced topics. ```bash - intro - dataflow - ui - markdown - plots - sql - layout - fileformat - external-dependencies - markdown-format - for-jupyter-users ``` -------------------------------- ### Run Marimo Layout Tutorial Source: https://docs.marimo.io/getting_started/key_concepts?q= Open the layout tutorial to learn about Marimo's tools for organizing and arranging outputs, including stacks, accordions, and tabs. ```bash marimo tutorial layout ``` -------------------------------- ### Use marimo Prebuilt Container in Dockerfile Source: https://docs.marimo.io/guides/deploying/prebuilt_containers Integrate a marimo prebuilt container into your Dockerfile. This example uses the latest SQL variant and sets the default command to start the marimo server. ```dockerfile FROM ghcr.io/marimo-team/marimo:latest-sql # Install any additional dependencies here CMD ["marimo", "edit", "--no-token", "-p", "8080", "--host", "0.0.0.0"] ``` -------------------------------- ### Run Marimo Tutorial Source: https://docs.marimo.io/getting_started/key_concepts Launch the dataflow tutorial to understand reactive execution and data flow within marimo notebooks. This command opens the tutorial in your default marimo environment. ```bash marimo tutorial dataflow ``` -------------------------------- ### Run Full Google Cloud Storage Example Source: https://docs.marimo.io/integrations/google_cloud_storage Execute the complete Google Cloud Storage example provided by marimo using the `marimo run` command. ```bash marimo run https://raw.githubusercontent.com/marimo-team/marimo/main/examples/cloud/gcp/google_cloud_storage.py ``` -------------------------------- ### Compatible Package Dependency (Pure Python Wheel) Source: https://docs.marimo.io/guides/lint_rules/rules/incompatible_package This example shows a package (requests) that is not flagged by the MW003 rule. It is compatible with WASM because it provides a pure Python wheel on PyPI, which can be installed via micropip. ```python import requests # Pure Python wheel on PyPI ``` -------------------------------- ### Initialize Data Science Project and Add Marimo Source: https://docs.marimo.io/guides/package_management/notebooks_in_projects?q= Set up a new data science project using `uv init` and add Marimo along with common data science libraries as project dependencies. This is for projects where notebooks are integral to the analysis workflow. ```bash # Initialize project uv init analysis-project && cd analysis-project # Add marimo as a project dependency uv add marimo pandas scikit-learn ``` -------------------------------- ### Running Marimo in Headless Mode on a Remote Server Source: https://docs.marimo.io/faq To run Marimo on a remote server, use the `--headless` flag and specify a port. This example shows how to start Marimo remotely and forward the port from your local machine. ```bash marimo edit --headless --port 8080 ``` ```bash marimo edit --headless --host 0.0.0.0 --port 8080 ``` ```text ssh -N -L 3718:127.0.0.1:8080 REMOTE_USER@REMOTE_HOST ``` -------------------------------- ### Run Full Google Cloud Storage Example Source: https://docs.marimo.io/integrations/google_cloud_storage?q= Execute a complete example demonstrating Google Cloud Storage integration with Marimo by running a provided Python script. ```bash marimo run https://raw.githubusercontent.com/marimo-team/marimo/main/examples/cloud/gcp/google_cloud_storage.py ``` -------------------------------- ### Sandbox Notebook PEP 723 Metadata Example Source: https://docs.marimo.io/guides/package_management/notebooks_in_projects?q= This header, automatically generated by `uv add --script`, defines the Python version and dependencies for a sandbox notebook. It also specifies the local path for editable installation of the package. ```toml # /// script # requires-python = ">=3.11" # dependencies = [ # "my-package", # "pandas", # "matplotlib", # ] # # [tool.uv.sources] # my-package = { path = "../", editable = true } # /// ``` -------------------------------- ### Get App Theme and Conditionally Set Plotting Theme Source: https://docs.marimo.io/api/app?q= Access the app's display theme using `mo.app_meta().theme`. This example shows how to conditionally enable a dark theme for Altair plots when Marimo is in dark mode. ```python import altair as alt import marimo as mo # Enable dark theme for Altair when marimo is in dark mode alt.themes.enable( "dark" if mo.app_meta().theme == "dark" else "default" ) ``` -------------------------------- ### Open MotherDuck example notebook Source: https://docs.marimo.io/integrations/motherduck?q= Open the MotherDuck example notebook in marimo to see a full demonstration of its integration. This command launches the specified notebook for editing. ```bash marimo edit https://github.com/marimo-team/marimo/blob/main/examples/sql/connect_to_motherduck.py ``` -------------------------------- ### Access Request URL Path and User Authentication Status Source: https://docs.marimo.io/api/app?q= Get the current HTTP request object via `mo.app_meta().request` to access user details and the request URL path. This example prints authentication status, username, and the URL path. ```python import marimo as mo request = mo.app_meta().request user = request.user print( user["is_authenticated"], user["username"], request.url["path"] ) ``` -------------------------------- ### Run Marimo Tutorials Source: https://docs.marimo.io/getting_started/key_concepts Use these commands to run specific Marimo tutorials from the command line. ```bash marimo tutorial markdown ``` ```bash marimo tutorial plots ``` ```bash marimo tutorial layout ``` ```bash marimo tutorial ui ``` ```bash marimo tutorial sql ``` -------------------------------- ### Run Marimo with MCP Support using uv Source: https://docs.marimo.io/guides/editor_features/mcp?q= Use uv to run Marimo with MCP support. This command installs the necessary dependencies and starts Marimo with the `--mcp` flag to expose the MCP server endpoint and `--no-token` for local development. ```bash # run with uv in a project uv run --with="marimo[mcp]" marimo edit notebook.py --mcp --no-token ``` -------------------------------- ### Install marimo SQL dependencies Source: https://docs.marimo.io/guides/working_with_data/sql?q= Install the necessary dependencies to enable SQL functionality in marimo. Choose the installation method that suits your package manager. ```bash pip install "marimo[sql]" ``` ```bash uv add "marimo[sql]" ``` ```bash conda install -c conda-forge marimo duckdb polars ``` -------------------------------- ### List Marimo Tutorials Source: https://docs.marimo.io/cli Command to display available marimo tutorials. ```text marimo tutorial --help ``` -------------------------------- ### Run Marimo Tutorial Source: https://docs.marimo.io/faq Run Marimo tutorials to learn about specific features like plots or layout. ```bash marimo tutorial plots ``` ```bash marimo tutorial layout ``` -------------------------------- ### Install Packages with micropip Source: https://docs.marimo.io/guides/wasm?q= Use `micropip` to install packages within a WebAssembly environment. Ensure `micropip` is imported in a separate cell before installing other packages. ```python import micropip ``` ```python await micropip.install("plotly") import plotly ``` -------------------------------- ### Install marimo pair with uvx Source: https://docs.marimo.io/guides/generate_with_ai/marimo_pair Install the marimo pair agent skill using uvx and Deno. This is an alternative installation method for the agent skill. ```bash uvx deno -A npm:skills add marimo-team/marimo-pair ``` -------------------------------- ### Run Marimo Markdown Tutorial Source: https://docs.marimo.io/getting_started/key_concepts?q= Access the markdown tutorial to learn how to use Marimo's dynamic markdown features for rich text and content integration. ```bash marimo tutorial markdown ``` -------------------------------- ### Run Marimo UI Tutorial Source: https://docs.marimo.io/getting_started/key_concepts?q= Execute this command in your terminal to launch the interactive UI tutorial for Marimo. ```bash marimo tutorial ui ``` -------------------------------- ### Install Marimo with Recommended Dependencies (uv) Source: https://docs.marimo.io/getting_started/quickstart?q= Installs marimo and its recommended optional dependencies using the uv package installer. This command is an alternative to using pip. ```bash uv add "marimo[recommended]" ``` -------------------------------- ### Run Marimo SQL Tutorial Source: https://docs.marimo.io/getting_started/key_concepts?q= Execute this command in your terminal to launch the SQL tutorial for Marimo, covering data querying capabilities. ```bash marimo tutorial sql ``` -------------------------------- ### Marimo New with Prompt Example Source: https://docs.marimo.io/cli?q= Generate a Marimo notebook from a specific prompt. This example shows how to create a notebook that plots an interactive 3D surface. ```bash marimo new "Plot an interactive 3D surface with matplotlib." ``` -------------------------------- ### Install pylsp with Marimo Source: https://docs.marimo.io/guides/editor_features/language_server?q= Install the python-lsp-server package along with Marimo for core Python language server features. This command also installs Ruff integration for linting. ```bash pip install "marimo[lsp]" # or uv add "marimo[lsp]" # or conda install -c conda-forge python-lsp-server python-lsp-ruff ``` -------------------------------- ### Install or Update Marimo with uv Source: https://docs.marimo.io/security?q= Use `uv` to install or upgrade marimo to the latest version, ensuring you have the most recent security fixes and improvements. This command installs or updates marimo to its latest release. ```bash # Install or update to the latest version uv pip install --upgrade marimo ``` -------------------------------- ### Run Marimo Plots Tutorial Source: https://docs.marimo.io/getting_started/key_concepts?q= Launch the plots tutorial to explore how to generate and display various types of plots within your Marimo notebooks. ```bash marimo tutorial plots ``` -------------------------------- ### Run Polars Example Notebook Source: https://docs.marimo.io/guides/working_with_data/dataframes?q= Open the comprehensive Polars example notebook using the marimo edit command. This notebook demonstrates the integration of Polars with Marimo. ```bash marimo edit https://raw.githubusercontent.com/marimo-team/marimo/main/examples/third_party/polars/polars_example.py ``` -------------------------------- ### Install marimo-operator Source: https://docs.marimo.io/guides/deploying/deploying_kubernetes?q= Apply the installation manifest to deploy the marimo operator on your Kubernetes cluster. ```bash kubectl apply -f https://raw.githubusercontent.com/marimo-team/marimo-operator/main/deploy/install.yaml ``` -------------------------------- ### Install marimo with recommended dependencies using conda Source: https://docs.marimo.io/getting_started/installation Install marimo with recommended dependencies using conda. This command installs additional packages for features like SQL cells, AI completion, and enhanced plotting. ```bash conda install -c conda-forge marimo "duckdb>=1.0.0" "altair>=5.4.0" pyarrow "polars>=1.9.0" "sqlglot[c]>=23.4" "openai>=1.55.3" "ruff" "nbformat>=5.7.0" "vegafusion>=2.0.0" "vl-convert-python>=1.0.0" ``` -------------------------------- ### Initialize Storage Client and List Buckets Source: https://docs.marimo.io/integrations/google_cloud_storage Load necessary libraries and initialize a StorageClient to interact with Google Cloud Storage. This code lists all available buckets. ```python # Cell 1 - Load libraries import marimo as mo from google.cloud import storage # Cell 2 - Load buckets client = storage.Client() buckets = client.list_buckets() ``` -------------------------------- ### Install pyrefly Source: https://docs.marimo.io/guides/editor_features/language_server Install pyrefly for completions, hover, go-to-definition, and diagnostics in Marimo. Requires Node.js. ```bash uv pip install pyrefly ``` -------------------------------- ### Run Marimo Dataflow Tutorial Source: https://docs.marimo.io/getting_started/key_concepts?q= Execute this command to launch the dataflow tutorial, which helps visualize and understand how data flows through your Marimo notebook. ```bash marimo tutorial dataflow ``` -------------------------------- ### Install ty Source: https://docs.marimo.io/guides/editor_features/language_server Install ty, a type checker from Astral, for diagnostics in Marimo. Requires Node.js. ```bash uv pip install ty ``` -------------------------------- ### Initialize Storage Client and List Buckets Source: https://docs.marimo.io/integrations/google_cloud_storage?q= Load necessary libraries and initialize a StorageClient to interact with Google Cloud Storage. This code lists all available buckets. ```python # Cell 1 - Load libraries import marimo as mo from google.cloud import storage # Cell 2 - Load buckets client = storage.Client() buckets = client.list_buckets() ``` -------------------------------- ### Initialize Library Project and Add Marimo Source: https://docs.marimo.io/guides/package_management/notebooks_in_projects Steps to initialize a new Python library project using uv and add Marimo as a development dependency. ```bash # Initialize the project uv init --lib my-library && cd my-library # Add marimo as development dependency uv add --dev marimo ``` -------------------------------- ### Text Area Example Source: https://docs.marimo.io/api/inputs/text_area?q= A minimal example demonstrating the instantiation of a text area UI element. ```python text_area = mo.ui.text_area() ``` -------------------------------- ### Install gspread and oauth2client Source: https://docs.marimo.io/integrations/google_sheets?q= Install the required Python packages for Google Sheets integration using pip. ```bash pip install gspread oauth2client ``` -------------------------------- ### Marimo Tutorial Command Usage Source: https://docs.marimo.io/cli?q= This shows the general usage pattern for the `marimo tutorial` command, including the required tutorial name and available options. ```bash marimo tutorial [OPTIONS] {intro|dataflow|ui|markdown|plots|sql|layout|fileformat|external-dependencies|markdown-format|for-jupyter-users} ``` -------------------------------- ### Run a Single Notebook as an App Source: https://docs.marimo.io/guides/apps Use the `marimo run` command to start a web server for a single notebook, displaying its outputs as an app. Code is hidden by default. ```text marimo run notebook.py ``` -------------------------------- ### Install Google Sheets Libraries Source: https://docs.marimo.io/integrations/google_sheets Install the required gspread and oauth2client Python packages using pip. ```bash pip install gspread oauth2client ``` -------------------------------- ### Install OpenAI Client Source: https://docs.marimo.io/guides/configuration/llm_providers Install the OpenAI client library for Python. This is a prerequisite for using most LLM providers. ```bash pip install openai ``` ```bash uv add openai ``` -------------------------------- ### Marimo Tutorial Command Usage Source: https://docs.marimo.io/cli This shows the general usage pattern for the `marimo tutorial` command, including the required tutorial name and available options. ```text marimo tutorial [OPTIONS] {intro|dataflow|ui|markdown|plots|sql|layout|fileformat|external-dependencies|markdown-format|for-jupyter-users} ``` -------------------------------- ### Install basedpyright Source: https://docs.marimo.io/guides/editor_features/language_server Install basedpyright for diagnostics (type checking errors and warnings) in Marimo. Requires Node.js. ```bash uv pip install basedpyright ``` -------------------------------- ### Install marimo with uv Source: https://docs.marimo.io/getting_started/installation Use this command to install marimo with uv. Ensure your virtual environment is activated. ```bash uv add marimo ``` -------------------------------- ### Marimo Convert Example (Markdown) Source: https://docs.marimo.io/cli Example of converting a Markdown file to a marimo notebook, saving to a file. ```text marimo convert your_nb.md -o your_nb.py ```