UV is Python package and project manager (virtual environment), written in Rust.
Self claimed: A single tool to replace pip, pip-tools, pipx, poetry, pyenv, twine, virtualenv, and more.
10-100x faster than pip
Read more at:
https://docs.astral.sh/uv/
This CheatSheet is close to
https://gist.github.com/rollingmountains
uv init myproject
cd myprojectuv inituv init --python 3.11uv venv # Create .venv in current directory
uv venv myenv # Create named environment
uv venv --python 3.11 # Specify Python versionls -la # Show .venv in current directory
find ~ -name ".venv" -type d 2>/dev/null # Find all .venv directories
uv venv list # List UV managed environments (if available)echo $VIRTUAL_ENV # Show active venv path
which python # Show active Python executable path
python -c "import sys; print(sys.prefix)" # Show Python environment prefix
pwd # Current directory (where .venv usually is)echo $VIRTUAL_ENV # Shows path if venv is active
ps1 # Check if prompt shows venv name
python --version # Check Python version in current envsource .venv/bin/activatedeactivate # Exit virtual environmentuv run python script.py # Auto-creates venv if neededuv add requests # Add package to project
uv add "django>=4.0" # Add with version constraint
uv add --dev pytest # Add as development dependency
uv add --optional test pytest # Add to optional groupuv remove requests # Remove package
uv remove --dev pytest # Remove dev dependencyuv pip install -r requirements.txt
uv sync # Install all project dependenciesuv lock --upgrade # Update lock file
uv sync # Sync to updated versionswhich python # Shows active Python path
echo $VIRTUAL_ENV # Shows active venv path
uv python list # List available Python versionsuv info # Show UV configuration
uv python find 3.11 # Find specific Python version
uv tree # Show dependency treeuv pip list # List packages in current env
uv pip show package_name # Show package detailsuv status # Show project sync status
uv check # Validate project dependenciesuv python install 3.11 # Install Python 3.11
uv python install 3.12 # Install Python 3.12
uv python list # List installed versionsuv python pin 3.11 # Pin project to Python 3.11uv run python script.py # Run with project venv
uv run --python 3.11 script.py # Run with specific versionuv run pytest # Run pytest in project env
uv run django-admin startproject mysiteuv lock # Generate uv.lock
uv lock --upgrade # Upgrade all dependenciesuv export > requirements.txt # Export to requirements.txt
uv export --dev > requirements-dev.txt # Include dev dependenciesrm -rf .venv # Delete .venv directoryuv cache clean # Clean package cache
uv cache dir # Show cache directoryexport UV_CACHE_DIR=~/.cache/uv # Set cache directory
export UV_TOOL_DIR=~/.local/share/uv/tools # Set tools directory
export UV_PYTHON_INSTALL_DIR=~/.local/share/uv/python # Python install dirmkdir myproject && cd myproject
uv init
uv add requests flask
source .venv/bin/activate
uv run python -c "import requests; print('Setup complete!')"cd existing_project
uv init
uv add package1 package2
uv sync
source .venv/bin/activate# If UV not found after installation
source ~/.bashrc # or ~/.zshrc
# Check if venv is activated
echo $VIRTUAL_ENV
# Reinstall UV
curl -LsSf https://astral.sh/uv/install.sh | sh
# Reset project environment
rm -rf .venv uv.lock
uv syncuv --verbose run python script.py # Verbose output
uv doctor # System diagnostics (if available)curl -LsSf https://astral.sh/uv/install.sh | shbrew install uvpipx install uvuv --versionuv self update