Tool-Python package and project manager-uv

📅 2026/7/27 6:22:22 👁️ 阅读次数 📝 编程学习
Tool-Python package and project manager-uv

Tool-Python package and project manager-uv

  • Home
  • GitHub Releases

An extremely fast Python package and project manager, written in Rust.

Install uv with our official standalone installer:

  • Linux/macOS:curl -LsSf https://astral.sh/uv/install.sh | sh
  • Windows:powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
~$ uv
An extremely fast Python package manager.Usage: uv [OPTIONS] <COMMAND>Commands:auth       Manage authenticationrun        Run a command or scriptinit       Create a new projectadd        Add dependencies to the projectremove     Remove dependencies from the projectversion    Read or update the project's versionsync       Update the project's environmentlock       Update the project's lockfileexport     Export the project's lockfile to an alternate formattree       Display the project's dependency treeformat     Format Python code in the projectaudit      Audit the project's dependenciestool       Run and install commands provided by Python packagespython     Manage Python versions and installationspip        Manage Python packages with a pip-compatible interfacevenv       Create a virtual environmentbuild      Build Python packages into source distributions and wheelspublish    Upload distributions to an indexworkspace  Inspect uv workspacescache      Manage uv's cacheself       Manage the uv executablehelp       Display documentation for a commandCache options:-n, --no-cache               Avoid reading from or writing to the cache,instead using a temporary directory for theduration of the operation [env: UV_NO_CACHE=]--cache-dir <CACHE_DIR>  Path to the cache directory [env: UV_CACHE_DIR=]Python options:--managed-python       Require use of uv-managed Python versions [env:UV_MANAGED_PYTHON=]--no-managed-python    Disable use of uv-managed Python versions [env:UV_NO_MANAGED_PYTHON=]--no-python-downloads  Disable automatic downloads of Python. [env:"UV_PYTHON_DOWNLOADS=never"]Global options:-q, --quiet...Use quiet output-v, --verbose...Use verbose output--color <COLOR_CHOICE>Control the use of color in output [possible values: auto, always,never]--system-certsWhether to load TLS certificates from the platform's nativecertificate store [env: UV_SYSTEM_CERTS=]--offlineDisable network access [env: UV_OFFLINE=]--allow-insecure-host <ALLOW_INSECURE_HOST>Allow insecure connections to a host [env: UV_INSECURE_HOST=]--no-progressHide all progress outputs [env: UV_NO_PROGRESS=]--directory <DIRECTORY>Change to the given directory prior to running the command [env:UV_WORKING_DIR=]--project <PROJECT>Discover a project in the given directory [env: UV_PROJECT=]--config-file <CONFIG_FILE>The path to a `uv.toml` file to use for configuration [env:UV_CONFIG_FILE=]--no-configAvoid discovering configuration files (`pyproject.toml`, `uv.toml`)[env: UV_NO_CONFIG=]-h, --helpDisplay the concise help for this command-V, --versionDisplay the uv versionUse `uv help` for more details.

Run a tool in an ephemeral environment using uvx (an alias for uv tool run)

Features

Python versions

Installing and managing Python itself.

  • uv python install: Install Python versions.
  • uv python list: View available Python versions.
  • uv python find: Find an installed Python version.
  • uv python pin: Pin the current project to use a specific Python version.
  • uv python uninstall: Uninstall a Python version.

Installing Python

Scripts

Executing standalone Python scripts, e.g., example.py.

  • uv run: Run a script.
  • uv add --script: Add a dependency to a script.
  • uv remove --script: Remove a dependency from a script.

Running scripts

Projects

Creating and working on Python projects, i.e., with a pyproject.toml.

  • uv init: Create a new Python project.
  • uv add: Add a dependency to the project.
  • uv remove: Remove a dependency from the project.
  • uv sync: Sync the project's dependencies with the environment.
  • uv lock: Create a lockfile for the project's dependencies.
  • uv run: Run a command in the project environment.
  • uv tree: View the dependency tree for the project.
  • uv build: Build the project into distribution archives.
  • uv publish: Publish the project to a package index.

Working on projects

Tools

Running and installing tools published to Python package indexes, e.g., ruff or black.

  • uvx / uv tool run: Run a tool in a temporary environment.
  • uv tool install: Install a tool user-wide.
  • uv tool uninstall: Uninstall a tool.
  • uv tool list: List installed tools.
  • uv tool update-shell: Update the shell to include tool executables.

Using tools

The pip interface

Manually managing environments and packages — intended to be used in legacy workflows or cases where the high-level commands do not provide enough control.

Creating virtual environments (replacing venv and virtualenv):

  • uv venv: Create a new virtual environment.

Using Python environments

Managing packages in an environment (replacing pip and pipdeptree):

  • uv pip install: Install packages into the current environment.
  • uv pip show: Show details about an installed package.
  • uv pip freeze: List installed packages and their versions.
  • uv pip check: Check that the current environment has compatible packages.
  • uv pip list: List installed packages.
  • uv pip uninstall: Uninstall packages.
  • uv pip tree: View the dependency tree for the environment.

Managing packages

Locking packages in an environment (replacing pip-tools):

  • uv pip compile: Compile requirements into a lockfile.
  • uv pip sync: Sync an environment with a lockfile.

Locking environments

Utility

Managing and inspecting uv's state, such as the cache, storage directories, or performing a self-update:

  • uv cache clean: Remove cache entries.
  • uv cache prune: Remove outdated cache entries.
  • uv cache dir: Show the uv cache directory path.
  • uv tool dir: Show the uv tool directory path.
  • uv python dir: Show the uv installed Python versions path.
  • uv self update: Update uv to the latest version.