Get help from the marimo community

Updated 2 months ago

marimo+uv workflow

I just tried
uv run --python 3.11 --with marimo --with numpy --with matplotlib marimo edit --sandbox hi.py
the equivalent pattern for jupyterlab would be
uv run --python 3.13 --with jupyterlab --with numpy --with matplotlib jupyter lab
but now I'm wondering:
When I start the marimo notebook notebook, why are the packages not installed?
Currently I get the error: The following packages were not found: "matplotlib" , "numpy" (see screenshot)
Attachments
image.png
image.png
1
M
J
A
50 comments
does it work if you use --with-requirements (and a req.txt) instead of --with?
maybe a formatting issue with the --with command
just tried
Plain Text
echo "pandas" > requirements.txt
uv run --with marimo --with-requirements "requirements.txt"  marimo edit --sandbox hi.py

but that did not work as well.
I also could not find the --with-requirements anywhere in the docs
https://marimo.io/blog/sandboxed-notebooks , https://docs.astral.sh/uv/concepts/tools/#including-additional-dependencies
Here's a workaround that does work:
Plain Text
uv add --script hi.py pandas matplotlib numpy    
uv run --with marimo  marimo edit --sandbox hi.py 
I wouldn’t chain “with” commands. That seems like an anti pattern and fragile
And honestly, I wouldn’t use uv directly and instead just use “marimo edit —sandbox”. I think it complicates it
—sandbox does for you what it looks like you are trying to achieve yourself, and hides away uv
That makes sense! But I don't have a global installation of marimo.
So I guess uvx marimo edit --sandbox hi.py would be the way to go then?
That works - curious why not globally install it? It’ll save you 4 keystrokes each time
how do I install marimo globally?
This is the correct way in my opinion (I’m no uv expert) to use uv if you don’t want to install it globally
Uv has a concept of tools - you can do “uv tool install marimo”. But that sits in its own venv - so I would only do that if you exclusively use sandbox
I see! And would that be locked to a specific python version?
lol it says the fix right there
yep, it's uv tool update-shell
just pasting the screenshot for documentation reasons, so that other members/LLMS can see the whole process.
and e.g. when I now want to use python 3.11, would that be also possible?
That's a good question. I'm not sure if uv tool / uvx (uvx is a shorthand for uv tool) supports having multiple installations of the tool across multiple Python versions. Your feedback and experiments are helpful, we're still learning best practices of how to use uv
small correction: accroding to their docs, uvx is a shorthand for uv tool run:
https://docs.astral.sh/uv/concepts/tools/#the-uv-tool-interface
Attachment
image.png
and next question:
I just ran marimovia uvx marimo edit --sandbox marimo_uv.py and I get the message ther there's an update available to marimo 0.9.8.
The terminal suggests me to usepip install marimo, but I guess it will be
uv pip install --upgrade marimo ?
Or should it be
uv tool install marimo --upgrade?
Attachment
image.png
I tried uv tool install marimo --upgrade now and that worked great 🍀
Attachment
image.png
some inputs on this from their discord
Attachment
image.png
Yea thats correct - we call uv run ourselves
(second cross-post of the answer)
I see! So in theory, the --python 3.11 flag could be called as well in that context?
We could pass the python flag to uv in our cli args.

Can you specify this with an environment variable?
Can you specific this with an environment variable?

II dont understand, can you explain this a bit more?
Sorry typo: specify

Can you set the python version using an env variable
Thanks for rephrasing, but I think I still don't understand the idea
The suggestion is to set UV_PYTHON=python3.11 instead of using the CLI flag: https://docs.astral.sh/uv/configuration/environment/
hey @Akshay , thanks for the suggestion!
Indeed, prepending the environment variable to the command does work 🎉
in my zsh shell im Mac I can install
UV_PYTHON=python3.11 uv tool install marimo
and then run
marimo edit hi.py
and it will run python3.11.

Similar I can run
UV_PYTHON=python3.13 uv tool install marimo
and then run
marimo edit hi.py to use python3.13
(screenshot for reference)
Attachment
image.png
For a one liner, you can even do the following:

Plain Text
UV_PYTHON=python3.13 uvx marimo edit hi.py
Awesome! But that I can also do with uvx --python 3.13 marimo edit hi.py , wich is maybe a bit cleaner.

But is
Plain Text
uvx --python 3.13  marimo edit hi.py
and
UV_PYTHON=python3.13 uvx marimo edit hi.py

100% identical?
As far as I can tell from their docs, yea
Awesome! Figuring out all this packaging stuff is like walking through fog, exploring and never knowing if you will reach the destiny.
But on the path I think I figured out some best practices that I'll use now when working with marimo, that I'll share right here.
  1. I'll have a global version of marimo installed via
uv tool install marimo
or with a specific python version using
UV_PYTHON=python3.11 uv tool install marimo (this will overwrite the previous global installation)
Furthermore, the global version of marimo can be updated via
uv tool install marimo --upgrade.
When I run a script with the global marimo version, I'll do that via
marimo edit hi.py --sandbox
When I run a script that already ran once with a --sandbox flag, I can simply omit this flag and run
marimo edit hi.py
The CLI tell me "This notebook has inlined package dependencies.
Run in a sandboxed venv containing this notebook's dependencies? [Y/n]" and I'll press "Enter" to continue

Now, when I don't want to use the global marimo, but a temporary marimo version instead, I'll run
uvx marimo edit --sandbox hi.py
this line is 100% identical to
uv tool run marimo edit --sandbox hi.py
because "uvx" is an alias to "uv tool run".

I can also specify a python version here, like this
uvx --python 3.13 marimo edit hi.py

The thing about uvx marimo is the following: It's not installed, it's just cached.
Runing uv cache clean will remove all artifacts from my system that were cached with uvx before.

Another option is to work with a virtual environment using uv:
Plain Text
uv venv
uv pip install marimo
uv run marimo edit hi.py

this venv can also be activated via source .venv/bin/activate and then marimo can be started via marimo edit hi.py .

And always, if I'm not sure what marimo installation I'm currently using, I can run which marimo and it will show me the file path.
Finally, I can also run marimo in a project with uv like this:
Plain Text
uv init (this will create a pyproject.toml file)
uv add marimo  (this will add "marimo>=0.9.9" to dependencies in pyproject.toml)
uv run marimo edit hi.py 
Thank you for writing this up!
Why would you use global vs non global marimo?
Can we use global marimo with a custom venv?
Is uv add marimo functionally different to uv pip install marimo?
Can we use global marimo with a custom venv?
I'm really interested in that question as well!
Add a reply
Sign up and join the conversation on Discord