uv is a fast and modern Python package, environment, and project manager that can:
- Install and manage Python versions (like
pyenv) - Handle dependencies and virtual environments (like
Poetry) - Run CLI tools without global installs (like
pipx)
List available Python versions:
uv python listInstall the latest Python 3 version:
uv python install 3Pin a Python version for the current directory/project:
uv python pin 3This creates a .python-version file specifying the chosen version.
Verify active Python:
which python
python --versionRun any Python CLI tool without global installation:
uv tool run <tool> [args]Or use the shorthand alias:
uvx <tool> [args]Example:
uv tool run pycowsay 'hello world!'
uvx pycowsay 'hello world!'Optionally, install a tool globally (cached for faster runs):
uv tool install <tool>List globally installed tools:
uv tool listuv init my-project cd my-projectThis initializes:
pyproject.tomlto manage dependencies.venv/directory for the virtual environment inside the project folder
source .venv/bin/activate # macOS/Linux
# Or on Windows PowerShell:
.venv\Scripts\Activate.ps1Or run commands within the environment without activating:
uv run python --version uv run pytestInstall runtime dependencies:
uv add <package-name>Install development dependencies:
uv add --dev <package-name>Remove dependencies:
uv remove <package-name>uv syncDisplay the dependency tree for installed packages:
uv treeInclude optional and dev dependencies:
uv tree --all-groupsList all installed packages in the active environment (like pip list):
uv pip listUpgrade all packages according to constraints and update the lockfile:
uv sync --upgradeUpgrade a specific package:
uv sync --upgrade-package <package-name>Upgrade a specific tool:
uv tool upgrade <tool-name>Upgrade all installed tools:
uv tool upgrade --all