Get help from the marimo community

Updated 5 months ago

How do I share marimo notebooks as files properly?

At a glance

The community member has created a Rye project with dependencies and a Marimo notebook using those dependencies. They want to share only the notebook without the Rye complications, so the person receiving the notebook can easily install the dependencies. The default Marimo install helper is not working because some of the dependencies are available only from a private Git repository or self-hosted PyPI alternatives.

The community members discuss several solutions, including using uv's support for inline script metadata to add dependencies, and a sidebar in Marimo for managing dependencies directly without leaving the notebook. The Marimo team responds that they have added the ability to add and remove dependencies without leaving Marimo, and this feature is now available in version 0.8.20.

Useful resources
So, my situation is simple:
  1. I've created a rye project and added some dependencies
  2. I've created a some_notebook.marimo.py with using some of those dependencies I've installed
  3. Now I want to share only a notebook, without all those rye complications
  4. The person who will download and open my marimo nb should be able to easily install those dependencies
The only reason why default marimo install helper is not working for me - because of some of the projects I use is available only from git+https://my-private-gitlab.com/... or self-hosted pypi alternatives (so there is a custom pypi index-url)

With jupyter I can use %pip install inside nb and that solves my problem, but how to do it inside marimo nb without creating a project or installing deps outside of marimo?
A
I
M
14 comments
Can you use uv’s support for inline script metadata?

uv add --script notebook.py <dep>

then the person receiving the notebook can open it with marimo edit --sandbox notebook.py which will open the notebook in a temporary environment with the packages installed: https://marimo.io/blog/sandboxed-notebooks
Looks cool!

but it is: uv add --script path/to/notebook.py scipy numpy torch
But still not that user-friendly. Maybe new section on sidebar with dependencies manager would be great. There I can install packages directly from marimo without waiting for no module was found and pop-up with installing option
and also mark them to be installed with or without first run of the current nb (if only 5 out of 6 packages is used in the current nb)
a sidebar for pkg management is something we can look into.

@Ilya I. Lubenets could you elaborate on:
and also mark them to be installed with or without first run of the current nb (if only 5 out of 6 packages is used in the current nb)
Imagine if I have two marimo notebooks. One of them is for downloading data via bs4 package. And the second is for EDA via plotly and pandas. So if I want to send somebody only the first one - I need to include only bs4 dep for first nb to share, without plotly and pandas.
@Ilya I. Lubenets this is what --sandbox does for you today (tracks imports and keeps them in sync in your inline-script metadata). is there something missing about this? or are you not using uv for your projects?
Yep, uv does a great job, but injecting deps in CLI outside of marimo is not a friendly way to do so. I’m only asking for ability to add and pin deps for nb without leaving marimo
Got it — we've added the first one, add and remove deps without leaving marimo (not yet released). If you're running with --sandbox, when adding and removing, the deps will be added/removed from the inline script metadata. We don't have a way yet to manually remove deps for the script metadata while keeping them installed in the environment
Wow, that was fast. Thank you! ❤️
@Ilya I. Lubenets, it's released! v0.8.20.
That super fast! Thank you!
Of course, thanks for the feature request!
Add a reply
Sign up and join the conversation on Discord