Python uv Advanced: Python Versions, pip Interface & Tool Installation
When requirements move from "as long as it runs" to "multi-version testing, backward-compatible pipelines, and global tool management," uv can handle it. This article takes you from solo dungeon runs to raiding as a team.
Python Version Management
uv has built-in Python download and management β no need to install pyenv separately.
# Install multiple versions
uv python install 3.10 3.11 3.12
# Pin a project to a specific version (creates .python-version)
uv python pin 3.11
# Create a venv with a specific version
uv venv --python 3.12
# Run with a specific version
uv run --python 3.10 pytestThe first time you use a version, it downloads automatically β subsequent uses go straight from cache.
pip-Compatible Interface
Existing CI, Docker, and scripts still using pip? uv provides a drop-in replacement:
# Equivalent to pip install -r requirements.txt
uv pip install -r requirements.txt
# Compile requirements (cross-platform, reproducible)
uv pip compile requirements.in --universal -o requirements.txt
# Sync environment (strictly from lockfile)
uv pip sync requirements.txt
# Create venv
uv venvSwitch to uv pip and the parameters are almost identical, but the speed jumps by an order of magnitude β like upgrading from a bicycle to a motorcycle: same road, completely different experience. Want to upgrade your legacy project without major changes? Start with uv pip, painless lift-off.
Global Tool Installation (uv tool)
Don't want to run uvx every time for tools you use frequently? Install them globally:
uv tool install ruff
uv tool install httpie
# Call directly afterward
ruff check .
http https://httpbin.org/getUpgrade individual tools or all of them at once:
uv tool upgrade ruff
uv tool upgrade --all
uv tool installcreates isolated environments that won't conflict with project dependencies. For project-pinned versions, still useuv add --dev.
Script Lockfile and Shebang
Want a single script to be reproducible too? You can lock its dependencies:
uv lock --script example.pyThis creates example.py.lock. When you run uv run example.py, it uses that lockfile.
Or make it executable:
#!/usr/bin/env -S uv run --script
# /// script
# dependencies = ["httpx"]
# ///
import httpx
print(httpx.get("https://example.com"))chmod +x fetch
./fetchNext Steps
With advanced capabilities mastered, use a set of guidelines to reduce risk: π Best Practices