
uv is one of those tools where there is pretty much no reason not to use it.
uv is a plug-n-play, drop in replacement for pip, pipx, pip-tools, venv, pyenv, virtualenv. uv is written in Rust so it is fast, like insanely fast. For someone that has used conda for a significant part of their Python journey, which has the speed of a wheelchair bound sloth with arthritis, it was like I was an American going out of the country for the first time. It was a godsend.
The company behind uv, Astral, is an actual legitimate VC backed startup, which means it commands resources necessary for ongoing development. Not all VC companies are evil that the tooling Astral creates like ruff and uv are some of the best in the Python ecosystem. I'm hoping they don't pull a redis or Terraform or something like that.
You can install uv both with their standalone installers or with any package manager of your choice. I've listed the most common options here:
Open your terminal and paste this:
curl -LsSf https://astral.sh/uv/install.sh | shOpen powershell and run this:
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"If you're not into pipe-to-shell installers (fair), you can use pip:
pip install uvFor the full list of installation options you should go to the official installation documentation here
Before you do anything you should add the shell autocompletion:
eval "$(uv generate-shell-completion bash)"You can then add this to either your ~/.bashrc or ~/.zshrc profiles so that it auto-loads in the future.
uv initCreating a new project is dead simple:
uv init my-project
cd my-projectThis scaffolds out a basic Python project with a `pyproject.toml` file. It's clean, minimal, and ready to go. You'll get a basic structure that looks like this:
my-project/
├── pyproject.toml
├── README.md
└── hello.pyuv runHere's where things get interesting. Forget about activating virtual environments manually. Just use:
uv run python hello.pyuv automatically creates and manages a virtual environment for you (in .venv), installs your dependencies, and runs your script. No activation needed. It just works.
You can also run modules directly:
uv run -m pytestuv add, uv removeAdding packages is painfully simple:
uv add requests
uv add pytest --devThis updates your pyproject.toml and installs the package. The --dev flag marks it as a development dependency.
Need to remove something?
uv remove requestsDone. No fuss.
uv lockThis is where uv shines. It creates a uv.lock file that pins exact versions of all your dependencies and their transitive dependencies:
uv lockThis lock file is cross-platform and ensures everyone on your team gets identical environments. It's like poetry.lock or Cargo.lock but faster.
uv syncGot a lock file from a teammate? Sync your environment to match it exactly:
uv syncThis installs everything from the lock file. Perfect for CI/CD or onboarding new developers.
uv treeEver wonder what's actually installed and why?
uv treeThis shows you a dependency tree of your project. You'll see what depends on what, making it easy to understand your dependency graph and spot issues.
uv initHere's where uv gets really powerful. You can manage multiple related packages in a single repository:
uv init my-monorepo --workspace
cd my-monorepo
uv init packages/core
uv init packages/cliYour root pyproject.toml defines the workspace:
[tool.uv.workspace]
members = ["packages/*"]Now you can:
This is game-changing for larger projects or internal tooling.
uv tool run, uvxNeed to run a tool without installing it globally?
uv tool run ruff check .Or use the shorthand uvx:
uvx ruff check .This downloads and runs the tool in an isolated environment. Think of it like npx for Python. No pollution of your global Python environment.
uv tool installFor tools you use regularly, install them globally:
uv tool install ruff
uv tool install blackThese live in isolation from your projects but are available system-wide. Update them with:
uv tool update ruffOr update everything at once:
uv tool update --allWant shell completions for your tools? Run:
uv tool update-shellThis refreshes shell completions for all installed tools.
uv publishReady to share your package with the world?
uv publishThis builds and uploads your package to PyPI. You'll need credentials configured, but the command handles the rest. Clean and simple.
uv_builduv now has its own build backend. In your pyproject.toml:
[build-system]
requires = ["uv-build>=0.1.0"]
build-backend = "uv_build"This means:
It's still early, but it's a sign of where Python packaging is heading.
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
Block quote
Ordered list
Unordered list
Bold text
Emphasis
Superscript
Subscript
asdsa