Skip to content

Instantly share code, notes, and snippets.

@4sskick
Created September 5, 2026 12:36
Show Gist options
  • Select an option

  • Save 4sskick/d41bdea8aa2249461f010379823afc89 to your computer and use it in GitHub Desktop.

Select an option

Save 4sskick/d41bdea8aa2249461f010379823afc89 to your computer and use it in GitHub Desktop.
A clean, hassle-free way to run Jupyter notebooks with `uv` and VS Code—without global installs, dependency conflicts, or kernel confusion. Covers one-off experiments, project-based environments, and adding packages directly from notebooks.

Stop Installing Jupyter Globally.

If you use Python + VS Code for ML, data science, or experiments, you probably have this problem:

Which Python environment is my notebook actually using?

Global Jupyter. Random pip install. Multiple virtualenvs. Broken kernels.

There’s a much cleaner setup:

uv + Jupyter + VS Code.

1. One-off experiment? No setup.

uv run --with jupyter --with pandas --with matplotlib jupyter lab

That's it.

uv creates a temporary isolated environment and throws it away afterward.


2. Real project? Let uv manage everything.

uv init --python 3.12

uv add --dev jupyterlab ipykernel
uv add pandas numpy matplotlib

uv run jupyter lab

Now your project owns:

pyproject.toml
uv.lock
.venv/

No global Python dependencies.


3. Make it a VS Code kernel

uv run ipython kernel install \
  --user \
  --env VIRTUAL_ENV $(pwd)/.venv \
  --name=my-project

Then:

VS Code → Select Kernel → my-project

Done.

Your notebook uses the same environment as your project.


4. And yes, you can add packages from the notebook

Instead of:

!pip install seaborn

Use:

!uv add seaborn

pyproject.toml and uv.lock stay in sync.


The whole workflow

uv init
   ↓
uv add dependencies
   ↓
uv run jupyter
   ↓
Select kernel in VS Code
   ↓
Start experimenting

No global Jupyter. No dependency guessing. No environment roulette.

If you're using uv already, this is probably the simplest way to make Jupyter feel like a first-class part of your Python project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment