How do I share marimo notebooks as files properly?

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?
12 Replies
Akshay
Akshay2mo ago
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
Serializing package requirements in marimo notebooks
How marimo enables sandboxed notebooks, reproducible down to the package environment
Ilya I. Lubenets
Ilya I. LubenetsOP2mo ago
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)
Myles Scolnick
Myles Scolnick2mo ago
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)
Ilya I. Lubenets
Ilya I. LubenetsOP2mo ago
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.
Myles Scolnick
Myles Scolnick2mo ago
@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?
Ilya I. Lubenets
Ilya I. LubenetsOP2mo ago
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
Akshay
Akshay2mo ago
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
Ilya I. Lubenets
Ilya I. LubenetsOP2mo ago
Wow, that was fast. Thank you! ❤️
Akshay
Akshay2mo ago
@Ilya I. Lubenets, it's released! v0.8.20.
Ilya I. Lubenets
Ilya I. LubenetsOP2mo ago
That super fast! Thank you!
Akshay
Akshay2mo ago
Of course, thanks for the feature request!