Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

docs: add docs for specifying python version while using --sandbox (#2837)

Myles Scolnicka73c34a613dd
diff --git a/docs/guides/editor_features/package_management.md b/docs/guides/editor_features/package_management.md
index 0c72f16772..ab8457a3bb 100644
--- a/docs/guides/editor_features/package_management.md
+++ b/docs/guides/editor_features/package_management.md
@@ -37,3 +37,23 @@ For example, whenever you add or remove a package, marimo will automatically upd
```
This means your notebook file is a completely self-contained artifact with all the necessary information to run.
+
+### Sandbox creation configuration
+
+Running marimo in a sandbox environment uses `uv` to create a virtual environment. You can use any of `uv`'s [supported environment variables](https://docs.astral.sh/uv/configuration/environment/).
+
+#### Choosing the Python version
+
+For example, you can specify the Python version using the `UV_PYTHON` environment variable:
+
+```bash
+UV_PYTHON=3.13 marimo edit --sandbox notebook.py
+```
+
+#### Other common configuration
+
+or you can use `uv`'s link mode:
+
+```bash
+UV_LINK_MODE="copy" marimo edit --sandbox notebook.py
+```
diff --git a/marimo/_server/api/endpoints/health.py b/marimo/_server/api/endpoints/health.py
index d6c959b0c6..3f64aef455 100644
--- a/marimo/_server/api/endpoints/health.py
+++ b/marimo/_server/api/endpoints/health.py
@@ -10,7 +10,11 @@ from starlette.responses import JSONResponse, PlainTextResponse
from marimo import __version__, _loggers
from marimo._server.api.deps import AppState
from marimo._server.router import APIRouter
-from marimo._utils.health import get_node_version, get_required_modules_list
+from marimo._utils.health import (
+ get_node_version,
+ get_python_version,
+ get_required_modules_list,
+)
if TYPE_CHECKING:
from starlette.requests import Request
@@ -76,6 +80,7 @@ async def status(request: Request) -> JSONResponse:
"mode": app_state.mode,
"sessions": len(app_state.session_manager.sessions),
"version": __version__,
+ "python_version": get_python_version(),
"requirements": get_required_modules_list(),
"node_version": get_node_version(),
"lsp_running": app_state.session_manager.lsp_server.is_running(),
diff --git a/marimo/_utils/health.py b/marimo/_utils/health.py
index 0b37c04e25..f9bf41d320 100644
--- a/marimo/_utils/health.py
+++ b/marimo/_utils/health.py
@@ -135,3 +135,7 @@ def get_chrome_version() -> Optional[str]:
return None
except FileNotFoundError:
return None
+
+
+def get_python_version() -> str:
+ return sys.version.split()[0]
diff --git a/tests/_server/api/endpoints/test_health.py b/tests/_server/api/endpoints/test_health.py
index 58be8836d5..4dde5c690e 100644
--- a/tests/_server/api/endpoints/test_health.py
+++ b/tests/_server/api/endpoints/test_health.py
@@ -33,6 +33,7 @@ def test_status(client: TestClient) -> None:
assert content["sessions"] == 0
assert content["version"] == __version__
assert content["lsp_running"] is False
+ assert content["python_version"] is not None
def test_version(client: TestClient) -> None: