5 ms·
Does anyone know a way to reuse that trick for jupyter notebooks? So that one could share a notebook declaring it's dependencies .
by Galanwe 2y ago
Does anyone know a way to reuse that trick for jupyter notebooks? So that one could share a notebook declaring it's dependencies .
- benrutter 2y agoNot 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!
- dagw 2y agoThat 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.
- benrutter 2y agoOooh, now that's glorious!
- dagw 2y agoThe 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.
- Galanwe 2y agoRight, 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.
- ionitist 2y agoI 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.
- stereo 2y agoThere 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.