This guide explains how to:
- Install
uv - Create a project with
pyproject.toml - Use a project-local
.venv - Add dependencies to the project
- Sync the environment
- Register the environment as a Jupyter kernel
- Use the kernel from Quarto
This workflow works well with modern editors because many IDEs
automatically detect a local .venv, and uv uses .venv
as the default project environment.
uv is a fast Python package and environment
manager written in Rust. It combines several common tools into a
single workflow.
uv handles:
- environment management (similar to
venv) - dependency management (similar to
pip) - project metadata using
pyproject.toml - optional lockfiles for reproducible environments
Compared with traditional setups such as venv + pip,
uv provides:
- much faster installs
- a simple command set (
uv add,uv sync) - automatic use of a project-local
.venv - native
pyproject.tomlsupport
This guide uses uv in a lightweight research workflow suitable for:
- Quarto projects
- Jupyter notebooks
- teaching materials
- exploratory analysis
The goal is to keep environments simple, local to the project, and easy to recreate.
curl -LsSf https://astral.sh/uv/install.sh | shReload your shell if necessary:
source ~/.zshrc
# or
source ~/.bashrcVerify installation:
uv --versionmkdir notes_py
cd notes_py
uv initThis creates a pyproject.toml file.
uv uses .venv as the default project environment.
Typical project layout:
notes_py/
├── pyproject.toml
├── uv.lock
└── .venv/
Many IDEs automatically detect .venv environments.
Example:
uv add jupyter pandas matplotlibTo use the environment with Jupyter or Quarto:
uv add --dev ipykerneluv syncThis creates or updates the .venv environment.
Jupyter does not automatically detect project environments.
To use the project’s .venv inside notebooks or Quarto,
we register it as a Jupyter kernel.
Run:
uv run python -m ipykernel install \
--user \
--name notes_py \
--display-name "Python (notes_py)"Explanation:
uv run pythonensures the Python interpreter inside.venvis used- `--name notes