{"slug": "pixi-adds-non-python-deps-to-python-notebooks", "title": "Pixi adds non-Python deps to Python notebooks", "summary": "Marimo's notebook sandboxes now support Pixi, letting standalone notebooks record Conda and PyPI requirements alongside their code, the marimo team announced. The integration, built with the Pixi team, allows a notebook to declare non-Python dependencies such as ffmpeg and pytorch-gpu for Pixi to install, so anyone with Pixi installed can open the notebook in marimo's interactive editor or run it as a script. The work also improved marimo's sandbox experience for uv users.", "body_md": "marimo’s [notebook\nsandboxes](https://docs.marimo.io/guides/package_management/sandboxes/) now\nsupport [Pixi](https://pixi.prefix.dev/). You can build and share standalone\nnotebooks with requirements from both [Conda](https://conda.org/) and\n[PyPI](https://pypi.org/) recorded alongside the code.\n\nFor example, this notebook uses marimo’s reactivity to drive GPU-accelerated\ntranscription with [Whisper](https://github.com/openai/whisper):\n\nWhen you choose a recording, marimo reruns Whisper to transcribe it. Whisper\nneeds [FFmpeg](https://ffmpeg.org/) to decode the audio and\n[PyTorch](https://pytorch.org/) to run the model, so the notebook declares\n[`ffmpeg` and `pytorch-gpu`](#pixi-dependencies)\nfor Pixi to install.\n\nSince these requirements are recorded in the notebook, anyone with\n[Pixi installed](https://pixi.prefix.dev/latest/installation/) can open it in\nmarimo’s interactive editor to edit the code and interact with its outputs:\n\n```\npixi exec marimo edit --sandbox=pixi https://raw.githubusercontent.com/marimo-team/marimo/main/examples/misc/pixi_whisper.py\n```\n\nOr execute the notebook as a Python script from the terminal, without opening the editor:\n\n```\npixi run --script https://raw.githubusercontent.com/marimo-team/marimo/main/examples/misc/pixi_whisper.py\n```\n\nWe built this integration with the Pixi team, improving marimo’s sandbox experience along the way for everyone—including uv users.\n\n## \n\nThe Pixi integration builds on how marimo’s [sandbox\nmode](https://docs.marimo.io/guides/package_management/sandboxes/) turns a\nnotebook’s requirements into a running environment.\n\nConsider a Python program that uses Polars.\n\n``` python\nimport polars as pl\n \npl.DataFrame({\n    \"city\": [\"London\", \"Paris\", \"Berlin\"],\n    \"temperature\": [18, 22, 20],\n})\n```\n\nThis program depends on Polars, which must be installed in the Python\n*environment* running it. Otherwise, the import raises a `ModuleNotFoundError`.\n\nTools like [uv](https://docs.astral.sh/uv/) and\n[Pixi](https://pixi.prefix.dev/) automate the setup. Instead of writing out a\nsequence of setup commands, you provide a *manifest*: a file listing the\nprogram’s dependencies and Python version requirements. The tool reads that\nfile, prepares an environment, and runs the program inside it.\n\n### \n\nFor a [project](https://docs.marimo.io/guides/package_management/projects/)\ncontaining related scripts and modules, it is common to keep the manifest in a\nseparate file, such as\n[pyproject.toml](https://packaging.python.org/en/latest/guides/writing-pyproject-toml/).\nPackage managers use that manifest to prepare an environment those programs\n*share*.\n\nBoth scripts share one environment.\n\nFor a standalone script, the Python file itself can serve as the manifest. [PEP\n723](https://peps.python.org/pep-0723/) defines a comment format for recording\nrequirements alongside the code, allowing a package manager to prepare an\nenvironment *only* for that script.\n\nEach script has its own environment.\n\nWe can give our Polars example its own manifest by adding a comment at the top of the file.\n\n```\n# /// script\n# requires-python = \">=3.12\"\n# dependencies = [\"polars>=1,<2\"]\n# ///\n \nimport polars as pl\n \npl.DataFrame({\n    \"city\": [\"London\", \"Paris\", \"Berlin\"],\n    \"temperature\": [18, 22, 20],\n})\n```\n\nWith the requirements recorded alongside the code, the script can be shared as\na single file. [uv](https://docs.astral.sh/uv/guides/scripts/) or\n[Pixi](https://pixi.prefix.dev/latest/python/scripts/) can prepare its\nenvironment and run it without separate setup instructions.\n\n### \n\nEvery marimo notebook is a [Python\nscript](https://docs.marimo.io/guides/scripts/), so the same two approaches\napply. A notebook can share a project’s environment or record its own\nrequirements inline.\n\n[Sandbox mode](https://docs.marimo.io/guides/package_management/sandboxes/)\nbuilds on package managers’ script support to manage the notebook’s environment\nfrom those inline requirements.\n\nAs you develop the notebook, you can install or remove packages through the\nPackages panel, or accept marimo’s [prompt to install a missing\ndependency](https://docs.marimo.io/guides/package_management/installing_packages/)\nwhen an import fails.\n\nmarimo records those changes in the notebook’s\n[inline metadata](#polars-dependencies)\nand synchronizes the *running* environment.\n\n``` python\nimport polars as pl\n \npl.DataFrame({\n    \"city\": [\"London\", \"Paris\", \"Berlin\"],\n    \"temperature\": [18, 22, 20],\n})\n```\n\nWith the requirements saved in the notebook, you or a collaborator can reopen it in a sandbox with\n\n```\nuvx marimo edit --sandbox notebook.py\n```\n\nOr run it as a script with\n\n```\nuv run notebook.py\n```\n\n## \n\nPython packages are often only part of what a notebook needs to run. As a cross-language package manager, Pixi can draw on the Conda ecosystem to bring the rest of those dependencies into the same environment. Here are a few examples of what that makes possible:\n\n### \n\nDeclare [`ffmpeg` as a Conda dependency](#ffmpeg-dependencies),\nand Pixi makes [FFmpeg](https://ffmpeg.org/) available to call from Python:\n\n``` python\nimport subprocess\n \noutput = subprocess.check_output([\"ffmpeg\", \"-version\"], text=True)\noutput.splitlines()[0]\nffmpeg version 9.0.2 Copyright (c) 2000-2026 the FFmpeg developers\n```\n\n### \n\nDeclaring `pytorch-gpu`[guarantees a CUDA-enabled build of PyTorch](https://pixi.prefix.dev/latest/python/pytorch/#installing-from-conda-forge),\nwith no extra indexes to configure. This cell checks that the installed build\nhas CUDA support:\n\n``` python\nimport torch\n \ntorch.backends.cuda.is_built()\nTrue\n```\n\n### \n\nThe Python package [rpy2](https://rpy2.github.io/doc/latest/html/overview.html)\nneeds an R installation to call R functions. Pixi provides the runtime alongside\nthe Python package:\n\n``` python\nimport rpy2.robjects as ro\n \nsummary = ro.r(\"summary(iris$Sepal.Length)\")\ndict(zip(summary.names, summary))\n{\n    \"Min.\": 4.3,\n    \"1st Qu.\": 5.1,\n    \"Median\": 5.8,\n    \"Mean\": 5.843333333333334,\n    \"3rd Qu.\": 6.4,\n    \"Max.\": 7.9,\n}\n```\n\nWith Pixi support, we can declare both\n[PyPI requirements (`marimo` and `rpy2`)](#r-dependencies)\nand [Conda requirements (`r-base`)](#r-dependencies)\nin the notebook. Opening the notebook in a Pixi sandbox installs both into one\nenvironment.\n\nCombining PyPI and Conda packages in one notebook opens up interactive analyses\nthat span languages and tools. For example, [moving a slider can filter a table\nin R](https://github.com/marimo-team/marimo/blob/main/examples/misc/pixi_r.py)\nand update marimo’s dataframe viewer:\n\nTry it out yourself:\n\n```\npixi exec marimo edit --sandbox=pixi https://raw.githubusercontent.com/marimo-team/marimo/refs/heads/main/examples/misc/pixi_r.py\n```\n\n## \n\nmarimo’s sandbox mode was originally built around\n[uv](https://docs.astral.sh/uv/), whose speed and early support for PEP 723\nmade per-notebook environments practical. Seeing how sandboxing made notebooks\neasier to author, share, and run, we wanted to bring the same experience to\nusers from the scientific computing community who rely on Pixi for dependencies\nbeyond Python.\n\nOver the past two SciPy conferences (and [a jigsaw\npuzzle](https://github.com/prefix-dev/pixi/issues/6632#issuecomment-5037377958)),\nwe got to know the Pixi developers and began discussing how to bring Pixi’s\ncapabilities to standalone Python scripts. We [advocated for building on PEP\n723](https://github.com/prefix-dev/pixi/issues/3751#issuecomment-2898979448),\nkeeping Python requirements in the standard fields and adding Pixi-specific\nconfiguration under `tool.pixi`. Together, we [landed support\nupstream](https://github.com/prefix-dev/pixi/pull/6648) for running scripts,\nmanaging their dependencies, and locking their environments.\n\nWith Pixi’s script support in place, we could [rework marimo’s sandbox\nimplementation](https://github.com/marimo-team/marimo/pull/10728) around a\ncommon model for both backends. Previously, starting a sandbox and changing its\npackages followed separate paths, which could let the running environment\ndiverge from the notebook’s recorded requirements.\n\nBoth operations now use the notebook’s manifest and the selected package\nmanager’s script commands to prepare and synchronize its environment. Those\ncommands respect [tool-specific\nconfiguration](https://docs.marimo.io/guides/package_management/sandboxes/#tool-specific-configuration)\nsuch as package indexes and sources, improving correctness for existing uv\nsandboxes as well as enabling Pixi.\n\nThe package manager uses the same notebook metadata to prepare the environment whether you work interactively in marimo or run the file as a script.\n\n## \n\nRevisiting sandboxing also let us improve setup and error recovery for both\nPixi and uv. The editor now opens while the environment is prepared, and the\n[Packages panel](https://docs.marimo.io/guides/package_management/) shows\nprogress and errors.\n\n**Edit manifest** lets you change the notebook’s requirements and package\nmanager settings directly. If setup fails, you can fix the manifest and retry\nwithout restarting marimo. The panel also tells you when a dependency change\nneeds a kernel restart.\n\n## \n\nTry one of the notebooks above, or [add a Pixi sandbox to your own\nnotebook](https://docs.marimo.io/guides/package_management/sandboxes/#conda-packages-with-pixi).\nPixi support is available in [marimo\n0.25.0](https://github.com/marimo-team/marimo/releases/tag/0.25.0) and later.\n\nOn a personal note, I’ve really enjoyed getting to know the Pixi team and\nworking with them on this feature. The opportunity to build bridges between\nopen-source projects is a big part of [what brought me to\nmarimo](https://trevorma.nz/blog/im-joining-marimo), and I feel fortunate to\nhave found work that keeps me connected to these communities.", "url": "https://wpnews.pro/news/pixi-adds-non-python-deps-to-python-notebooks", "canonical_source": "https://marimo.io/blog/pixi-sandboxes", "published_at": "2026-09-28 08:53:01+00:00", "updated_at": "2026-09-28 09:19:59.820809+00:00", "lang": "en", "topics": ["developer-tools", "ai-tools", "ai-infrastructure"], "entities": ["marimo", "Pixi", "Conda", "PyPI", "Whisper", "FFmpeg", "PyTorch", "uv"], "also_reported_by": [], "alternates": {"html": "https://wpnews.pro/news/pixi-adds-non-python-deps-to-python-notebooks", "markdown": "https://wpnews.pro/news/pixi-adds-non-python-deps-to-python-notebooks.md", "text": "https://wpnews.pro/news/pixi-adds-non-python-deps-to-python-notebooks.txt", "jsonld": "https://wpnews.pro/news/pixi-adds-non-python-deps-to-python-notebooks.jsonld"}}