Python notes

features

Features

Python versions (Python management):

  • uv python install: Install Python versions
  • uv python list: View available versions
  • uv python find: Locate an installed Python version
  • uv python pin: Pin a version for the project
  • uv python uninstall: Remove a managed Python version

Scripts (Standalone Python scripts):

  • uv run: Execute a script with dependencies
  • uv add --script: Add dependencies to a script
  • uv remove --script: Remove script dependencies

Projects (Projects using pyproject.toml):

  • uv init: Create a project
  • uv add: Add project dependency
  • uv remove: Remove dependency
  • uv sync: Install dependencies in the project environment
  • uv lock: Generate or update uv.lock
  • uv run: Run a command in the project environment
  • uv tree: Show dependency tree
  • uv build: Build source and wheel distributions
  • uv publish: Publish the package to a registry

Tools (Python CLI tools like ruff, black):

  • uvx, uv tool run: Run tool in a temporary env
  • uv tool install: Install a tool persistently
  • uv tool uninstall: Remove installed tool
  • uv tool list: Show installed tools
  • uv tool update-shell: Update PATH for tool binaries

Pip interface (Manual environment and package management):

Note: pip compatibility is approximate; differences may appear in complex workflows.

  • Virtual envs:
    • uv venv: Create a virtual environment
  • Package management:
    • uv pip install: Install packages
    • uv pip show, uv pip list, uv pip freeze: Inspect packages
    • uv pip check: Verify environment compatibility
    • uv pip uninstall: Uninstall packages
    • uv pip tree: Show dependency tree
  • Locking:
    • uv pip compile: Create lockfiles
    • uv pip sync: Sync environment to lockfile

Utility commands (Inspect or update state):

  • uv cache clean: Clear cache
  • uv cache prune: Remove unused/outdated cache entries
  • uv cache dir: Show cache directory path
  • uv tool dir: Show tool install directory path
  • uv python dir: Show managed Python directory path
  • uv self update: Update uv to the latest version