uv install Quickstart
Last Update:
Word Count:
Read Time:
Page View: loading...
Installing [uv] and Managing Your Python Projects
uv
is a seriously fast and efficient tool for Python package management, written in Rust. It’s a great alternative to pip
and virtualenv
, speeding up your workflow significantly. Let’s get you set up and show you how to use it.
Installing [uv]: Three Ways
You’ve got a few simple options for getting uv
onto your system:
- Recommended (with
pipx
): This is the best way as it installsuv
in its own isolated environment, preventing conflicts with other packages.1
2
3pip install pipx # If you don't have pipx already
pipx ensurepath # Make sure pipx's executables are on your PATH
pipx install uv - Directly with
pip
: A straightforward way if you prefer not to usepipx
.1
pip install uv
- Using
brew
(macOS/Linux): If you’re on macOS or Linux and use Homebrew, it’s just one command.1
brew install uv
Setting Up and Activating a Virtual Environment
uv
makes managing virtual environments a breeze, keeping your project dependencies neatly separated.
Creating the Environment
To create a new virtual environment in your current directory (it’ll be named .venv
by default):
1 |
|
or you can assign specific version of Python
1 |
|
Activating the Environment
Before you do anything else in your project, you need to activate this environment:
- macOS/Linux:
1
source .venv/bin/activate
- Windows (Command Prompt):
1
.venv\Scripts\activate.bat
- Windows (PowerShell):
1
.venv\Scripts\Activate.ps1
You’ll know it’s active because your terminal prompt will usually show (.venv)
at the beginning.
Exit can use following:1
deactivate
Delete the .venv directory:1
rm -rf .venv
Installing Packages with [uv pip install]
Once your virtual environment is active, installing packages is very similar to pip
, but with uv pip
:
- Installing from
requirements.txt
:1
uv pip install -r requirements.txt
- Installing individual packages:
1
uv pip install requests beautifulsoup4
Important Note on Quoting with [uv pip]
When installing packages that include extras (optional features) or direct URLs, you must use double quotes to ensure the shell passes the entire string correctly to uv
. This is a common point of confusion for pip
users moving to uv
.
- With extras:
1
uv pip install "celery[redis]"
- From a Git repository:
1
uv pip install "git+https://github.com/example/my-lib.git#egg=my-lib"
- Local editable installs:
1
uv pip install "-e ."
Running Your Project with [uv]’s Python
After your environment is active and dependencies are installed, you simply use the python
command, which now refers to the Python interpreter within your activated .venv
.
If you have a script named app.py
:
1 |
|
Key point: You don’t use uv python
(that command doesn’t exist). Once the environment is activated, your shell automatically uses the python
from your .venv
.
What Makes [uv] Special?
uv
isn’t just another package manager; it brings some powerful features to the table:
Blazing Speed: This is
uv
‘s headline feature. Written in Rust, it’s significantly faster thanpip
for dependency resolution and installation, especially in large, complex projects.Robust Dependency Resolution:
uv
is designed to handle complex dependency graphs and potential conflicts much more effectively thanpip
, leading to more reliable builds.No Global Lock (for venvs): Unlike some other tools,
uv
doesn’t enforce a global lock file across all your virtual environments. Eachuv venv
operates independently, which simplifies development when you’re juggling multiple projects with different dependency versions. You can manage project-specific lock files (e.g.,uv lock
) if desired, but it’s not imposed globally.Integrated Installer and Resolver:
uv
combines the roles ofpip
(installer) andpip-tools
orPoetry
(resolver) into a single, cohesive tool.