Back to blog

Streamlining Python Projects: Effortless Virtual Environments with uv

Managing Python dependencies can be a hassle, but uv makes it fast and simple. I've been using this as my go-to virtual environment setup.

Here’s how you can get started with using uv in your workflow:

Getting Started

Install uv

macOS/Linux
curl -LsSf https://astral.sh/uv/install.sh | sh
Windows (PowerShell)
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"

Verify installation

Check your uv version to confirm it's installed correctly.

uv --version

Essential uv Commands

Initialize a project

uv init

Sets up pyproject.toml and uv.lock if missing. When starting a new project, use uv init to create the necessary configuration files.

Create a virtual environment

uv venv
source .venv/bin/activate

Sets up an isolated environment. Run uv venv and activate it with source .venv/bin/activate.

Add dependencies

uv add <package>

Installs and locks the package in your project files. Use uv add <package> whenever you need a new dependency—no extra steps required.

Update lock file

uv lock

Regenerates uv.lock after manual edits to pyproject.toml. Keeps your environment consistent and reproducible.

Sync environment

uv sync

Installs all dependencies from uv.lock. Use this for fresh setups or after pulling changes to ensure your environment matches the project.

Quick tips

  • After uv add, you don’t need to run uv lock or uv sync—it’s all handled.
  • Use uv sync when setting up or updating your environment.
  • Use uv lock only to update the lock file without installing.

uv is a modern, ultra-fast tool for Python dependency management. It simplifies setup, keeps environments reproducible, and makes collaboration seamless. Give it a try for your next project!

For more details, visit the uv documentation.