Using Jupyter with uv

Thanks for your interest @krassowski!
I’ll elaborate a bit more on this.

Firstly, it’s faster.
On macOS, this is the status quo on how I would install Jupyter with brew:

1. install brew
2. install python
3. make a virtual environment
4. activate environment
5. install jupyter
6. start jupyter lab

It takes about 5 minutes for the steps 2-6 (video documentation here)
With UV, this simplifies to

1. install uv
2. uvx jupyter lab

this takes about 30 seconds (video documentation here)

It’s faster because you have to memorize and write fewer lines of code, but also uv itself is 10-100x faster than pip (according to their docs uv).

Then, It’s also more flexible. In the status quo, I’d have to run steps 2-6 again if I wanted to test different python versions, that includes creating and deleting virtual environments every time. With uv on the other hand, it automatically fetches the right python version, e.g. by using

uvx --python 3.12 jupyter lab
uvx --python 3.13 jupyter lab

Another thought about the flexibility: You can run notebooks without activating virtual environments. uv internally caches dependencies, and then quickly rebuilds the one-time environment on the fly (as far as I understand).

As a final note, I want to mention that marimo notebooks (not jupyter notebooks though) can include 3rd-party dependencies within the script, based on PEP 722 – Dependency specification for single-file scripts | peps.python.org
That means that I can e.g. run this gist
with just a single command uvx marimo edit --sandbox color_picker.py and it will fully reproduce my notebook, including all dependencies. Would be amazing if that would work for jupyter notebooks as well!

3 Likes