If you’ve ever worked with Jupyter Notebooks, you know the pain:
- One notebook runs on Python 3.10, another wants 3.11.
- Some depend on
torch==2.1.0
, others break unless it’s2.0.1
. - And don’t even get me started on dependency conflicts when you’re switching between projects.
Traditional tools like pip
+ venv
work fine, but they can feel slow and clunky. Enter uv
, a blazing-fast Python package manager + environment manager.
Think of uv
as the next-gen replacement for pip/venv/poetry. It makes project setup faster, cleaner, and way more consistent. And yes, you can use it seamlessly with Jupyter Notebooks.
Here’s how to set it up 👇
Setup Instructions
We’ll register a new Jupyter kernel that uses a uv
-managed environment.
1. Install project dependencies
Inside your project folder:
uv install
# or
uv sync
💡 Requires uv
installed globally. If you don’t have it yet:
curl -LsSf https://astral.sh/uv/install.sh | sh
or follow the official install guide.
2. Register a Jupyter kernel for your project
For example, let’s say we’re working on Virtus (my deepfake detection model):
uv run python -m ipykernel install --user --name vitrus --display-name "Python (vitrus)"
This creates a new Jupyter kernel tied directly to your uv
environment.
3. Add the new kernel to Jupyter
- In PyCharm: just open the
.ipynb
file and select Python (myenv) from the top-right kernel selector.
- In Jupyter Lab / Notebook: switch kernels from the dropdown menu to use your shiny new environment.
4. Remove old kernels
After your work is done, Clean up the messy leftovers:
jupyter kernelspec list
Output will look like:
Available kernels:
python3 /home/you/.local/share/jupyter/kernels/python3
lopt /home/you/.local/share/jupyter/kernels/lopt
vitrus /home/you/.local/share/jupyter/kernels/vitrus
To remove one:
jupyter kernelspec uninstall vitrus
Why bother with uv
?
- Speed: installs packages ridiculously fast (thanks to Rust).
- Isolation: each project gets a clean, dedicated env.
-
Reproducibility:
uv.lock
means no “works on my machine” nonsense. - Jupyter-friendly: easy kernel registration, no hacky workarounds.
👉 My recommendation: set up your Jupyter projects with uv
, and you’ll avoid 90% of Python environment headaches. Do it once per project and you’re golden.
Top comments (0)