What is uv?

  • uv is an extremely fast Python package and project manager, written in Rust by Astral. 1
  • It replaces several separate tools you’d otherwise need — pip, venv, pip-tools, pipx, and poetry — with a single command, uv.
  • uv can install Python itself, create and manage virtual environments, install packages, and run your scripts, all without you needing to manually activate or deactivate an environment.

Why Use uv?

  • Speed: uv is commonly 10-100x faster than pip at resolving and installing packages.
  • One tool instead of many: no more juggling pip, venv, and separate installers.
  • Automatic environment management: uv run automatically creates and uses a virtual environment for your project. You don’t have to remember to activate or deactivate anything.
  • Reproducible installs: uv creates a lockfile so that everyone running your project gets the exact same package versions.
  • Manages Python versions too: uv can download and manage specific Python versions for you if you don’t already have one installed.

How Can I Install uv? (Mac)

  • Open the VS Code Terminal and run:
1curl -LsSf https://astral.sh/uv/install.sh | sh
  • Alternatively, if you use Homebrew:
1brew install uv

How Can I Install uv? (Windows)

  • In the VS code terminal, run:
1pip install uv
  • Reference: pypi.org

  • Alternatively you can use the standalone installer. Open PowerShell and run:

powershell
1powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"

How Can I Test That uv Is Installed?

  • Close and reopen all terminals (so it picks up the new install), then run:
1uv --version
  • If installed correctly, you’ll see output similar to:
1uv 0.11.29

How Do I Use uv to Run a Script?

  1. In your project folder, initialize a uv project (only needs to be done once per folder):
1uv init
  • This creates a pyproject.toml file and a .venv folder that uv will manage for you.
  1. Instead of running your Python files with python filename.py, run them with:
1uv run filename.py
  • uv run automatically creates the virtual environment (if it doesn’t already exist) and installs any needed packages before running your script — no manual activate/deactivate steps required.

  • Reference: Running Scripts with uv


How Do I Add or Remove Packages with uv?

  • To add a package to your project, use uv add. This installs the package into your .venv and updates pyproject.toml and the lockfile:
1uv add pandas
  • You can add multiple packages at once:
1uv add pandas plotly
  • To remove a package, use uv remove. This uninstalls it from .venv and updates pyproject.toml and the lockfile:
1uv remove pandas
  • After running uv add or uv remove, just run your script with uv run filename.py as usual — uv keeps the environment in sync automatically, no separate install or activation step needed.

  • Reference: Managing Dependencies with uv


Footnotes

  1. uv Python package manager, by Astral.