Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Does anyone know a way to reuse that trick for jupyter notebooks? So that one could share a notebook declaring it's dependencies .


Not sure it's as performant, but jupyter notebooks can install dependencies at run time with `!pip install my_cool_library==2.3.1`.

If feels a little bit less elegant, and you don't get access to uv's caching goodness, but that'd more or less achieve what you're looking for!


That works with uv as well. Launch Jupyter with

   uv tool run jupyter lab
and then put

   !uv pip install my_cool_library
   !uv pip install other_library
   ...
in the first cell. Now you get full uv caching goodness.


Oooh, now that's glorious!


The only thing to be aware of with this approach is that you don't get an isolate venv for each notebook. So if you're working on one notebook that needs my_lib 1.X and one that needs my_lib 2.X you'll need to manually create separate venvs for each and make sure you start Jupyter in the right venv for each notebook.


Right, though that requires an existing virtualenv with jupyter in the first place.

I was more dreaming of something where I can send a notebook to someone not technical, and that just bootstraps on the fly an env with jupyter and the required dependencies.


I don't know of a way to do this for jupyter, but marimo (alternative notebook environment to jupyter) does support self declared dependencies, and indeed uses uv to provide that support.


There are libraries like `juv` that let you use uv in Jupyter. What I haven’t found yet is a nice and convenient way of running all that in vs code.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: