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.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
fix: lazy import psutil for windows (#7411)
Dylan Madisettiad79ff19eb60
diff --git a/marimo/_cli/upgrade.py b/marimo/_cli/upgrade.pyindex e890654edd..25d9ac8070 100644--- a/marimo/_cli/upgrade.py+++ b/marimo/_cli/upgrade.py@@ -7,8 +7,6 @@ import urllib.errorfrom datetime import datetimefrom typing import Any, Callable, cast-import psutil-import marimo._utils.requests as requestsfrom marimo import _loggersfrom marimo._cli.print import echo, green, orange@@ -41,6 +39,11 @@ def print_latest_version(current_version: str, state: MarimoCLIState) -> None:def _is_in_uv() -> bool:+ try:+ import psutil+ except Exception:+ # No warning, since this is just used for cosmetics.+ return Falsereturn psutil.Process(os.getppid()).name() == "uv"diff --git a/pixi.lock b/pixi.lockindex ddc976285e..dea4966659 100644--- a/pixi.lock+++ b/pixi.lock@@ -1101,8 +1101,8 @@ packages:timestamp: 1727801725384- pypi: ./name: marimo- version: 0.18.1- sha256: b89cff1b4327d087653d929b56b08026b0b690464da595eb8bb4d5dbadc971e1+ version: 0.18.2+ sha256: 5404184c973dc3548bc7a266049ea893740b5d352a24d8606a1800fad7b2e008requires_dist:- click>=8.0,<9- jedi>=0.18.0diff --git a/pyproject.toml b/pyproject.tomlindex dfbc62f59c..f5a8943088 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -472,6 +472,7 @@ banned-module-level-imports = ["packaging","pandas","polars",+ "psutil","pyarrow","redis","sqlalchemy",diff --git a/tests/_messaging/test_variables.py b/tests/_messaging/test_variables.pyindex 66f75e43b9..5cc9b2a533 100644--- a/tests/_messaging/test_variables.py+++ b/tests/_messaging/test_variables.py@@ -3,7 +3,6 @@ from __future__ import annotationsimport osfrom typing import Any-import psutilimport pytestfrom marimo._dependencies.dependencies import DependencyManager@@ -157,6 +156,7 @@ def test_get_variable_preview() -> None:def test_get_variable_preview_memory_numpy() -> None:# Test memory usage with large arrayimport numpy as np+ import psutilprocess = psutil.Process(os.getpid())@@ -177,6 +177,8 @@ def test_get_variable_preview_memory_numpy() -> None:def test_get_variable_preview_bytesarray() -> None:+ import psutil+process = psutil.Process(os.getpid())# Create 100MB bytesarray@@ -203,6 +205,8 @@ def test_get_variable_preview_bytesarray() -> None:create_dataframes({"A": list(range(1000000)), "B": ["x"] * 1000000}),)def test_get_variable_preview_dataframe(df: Any) -> None:+ import psutil+process = psutil.Process(os.getpid())mem_before = process.memory_info().rss