C.W.K.
Stream
Lesson 03 of 05 · published

Daily uv Commands

~13 min · uv, commands, workflow

Level 0Newbie
0 XP0/55 lessons0/16 achievements
0/80 XP to next level80 XP to go0% complete

uv has two CLI surfaces. uv pip ... is the drop-in pip replacement — every pip flag works. uv add / uv run / uv sync is the modern uv-native workflow — what you'll use for new projects.

uv init <name> creates a new project (pyproject.toml + .python-version + initial src layout). uv add <pkg> adds a dep — automatically creates the venv if needed, installs the package, updates uv.lock. uv add --dev <pkg> adds a dev dep. uv remove <pkg> removes one (and CLEANLY removes orphaned transitive deps, unlike pip).

uv run <cmd> runs a command in the project's venv — automatically activates the venv first, then runs. No more source .venv/bin/activate. uv run pytest, uv run python main.py, uv run flask --app server run all just work.

uv python install <version> installs a managed Python — replaces pyenv. uv python pin <version> pins this project to that version (writes .python-version). uv sync reproduces the project's exact state from uv.lock.

uvx <tool> is uv's npx / pipx run — runs a tool without installing it permanently. uvx ruff check ., uvx black . — try a tool without committing. uv tool install <tool> installs a tool globally (replaces pipx install).

Code

Modern uv workflow — new project from scratch·bash
# Bootstrap
uv init myproject && cd myproject
# creates pyproject.toml, .python-version, src/myproject/__init__.py

# Pin Python version
uv python pin 3.13

# Add deps
uv add flask sqlalchemy
uv add --dev pytest ruff mypy

# Run things — auto-activates venv
uv run python -c "import flask; print(flask.__version__)"
uv run pytest
uv run flask --app server run

# Lock reproducibility
# (uv.lock is auto-generated and updated by 'uv add' / 'uv lock')
uv sync                    # install exactly what uv.lock says
Drop-in pip replacement·bash
# In an existing pip-based project, you can use uv as faster pip
uv pip install requests
uv pip install -r requirements.txt
uv pip freeze
uv pip list
uv pip uninstall requests

# Same flags, same behavior, dramatically faster.
# This is the zero-friction migration path.
Tools — replaces pipx·bash
# Run a tool without installing (replaces 'pipx run')
uvx ruff check .
uvx black .
uvx httpie https://example.com

# Install a tool globally (replaces 'pipx install')
uv tool install ruff
uv tool install black
uv tool list
uv tool upgrade --all

External links

Exercise

Bootstrap a new project: 'uv init scratch && cd scratch && uv add flask requests pytest && uv run python -c "import flask; print(flask.__version__)"'. The whole sequence should take seconds. Look at pyproject.toml and uv.lock — they're the entire reproducibility story.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.