Skip to content

Instantly share code, notes, and snippets.

@razhangwei
Last active March 17, 2025 05:16
Show Gist options
  • Save razhangwei/dc91a0603431941d5db3975231494621 to your computer and use it in GitHub Desktop.
Save razhangwei/dc91a0603431941d5db3975231494621 to your computer and use it in GitHub Desktop.
#python UV

Key Features

  • 10-20x faster than pip
  • Written in Rust for high performance
  • Single static binary (no Python dependency)
  • Compatible with pip command interface
  • Can replace pip, pip-tools, and virtualenv
  • Efficient dependency resolution

UV Python Package Manager Cheatsheet

Installation

# Install uv
curl -LsSf https://astral.sh/uv/install.sh | sh

Virtual Environment Management

# Initial with a typical UV project structure (e.g., pyproject.toml, uv.lock, README.md, etc)
uv init [directory]

# Create venv in .venv automatically
uv venv 

# add package dependency to pyproject.toml
uv add [package]

# Create a virtual environment
uv venv 

# Create a virtual environment with specific Python version
uv venv --python=python3.10 [directory]

# Activate virtual environment (in bash/zsh)
source [directory]/bin/activate

Package Installation

# Install packages
uv pip install [package]

# Install from requirements.txt
uv pip install -r requirements.txt

# Install with specific Python version
uv pip --python=python3.10 install [package]

# Install development packages
uv pip install -e .

Package Management

# List installed packages
uv pip list

# Show package information
uv pip show [package]

# Upgrade a package
uv pip install --upgrade [package]

# Uninstall a package
uv pip uninstall [package]

Tool Installation

# Install Python tools (like ruff, black, etc.)
uv tool install [tool]

# Install a specific version
uv tool install [tool]==[version]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment