LinuxCommandLibrary

uv-python

Install and manage Python packages using uv

TLDR

List all available Python installations

$ uv python list
copy

Install a Python version
$ uv python install [version]
copy

Uninstall a Python version
$ uv python uninstall [version]
copy

Search for a Python installation
$ uv python find [version]
copy

Pin the current project to use a specific Python version
$ uv python pin [version]
copy

Show the uv Python installation directory
$ uv python dir
copy

SYNOPSIS

uv python SUBCOMMAND [OPTIONS]

PARAMETERS

install VERSION_SPEC
    Installs a specified Python interpreter version (e.g., 3.9, 3.10.12). uv will download and install the requested version if not already present.

list
    Lists the Python interpreter versions managed or known by uv on your system.

pin VERSION_SPEC
    Pins a specific Python interpreter version for the current directory by creating a .python-version file, similar to pyenv local.

find
    Locates Python interpreters available on the system, including those installed by uv or other means.

--with TOOL
    (Common Option for 'install') Installs additional tools alongside the Python interpreter, such as 'pip' or 'venv'. Example: --with pip.

--force
    (Common Option) Forces an operation, such as re-installing an interpreter that already exists.

--target PATH
    (Common Option for 'install') Specifies the directory where the Python interpreter should be installed. By default, uv manages interpreters in a central location.

DESCRIPTION

uv python is a subcommand of the uv tool, a high-performance Python package installer and resolver written in Rust. While uv itself primarily replaces pip and venv, the uv python subcommand extends its capabilities to directly manage Python interpreters. It offers functionality to install specific Python versions, list available or installed interpreters, and pin project-specific Python versions, similar to tools like pyenv. This integration streamlines the entire Python development workflow, allowing users to manage both environments and packages with a single, incredibly fast utility. Its focus on speed and reliability makes it an attractive alternative for developers seeking a more efficient way to handle their Python toolchain.

It aims to be a modern, all-in-one replacement for many common Python environment and package management tasks.

CAVEATS

uv and its uv python subcommand are relatively new tools, actively under development. While extremely fast and robust, they may not yet cover all niche use cases or offer the full configurability of more established tools like pyenv or conda.

Ensure you have the necessary system dependencies (like build tools for some Python versions) if installing from source.

SPEED AND PERFORMANCE

Built in Rust, uv python inherits the performance benefits of uv, offering significantly faster Python interpreter installation and management compared to traditional methods. This speed is a core design principle, making it ideal for CI/CD pipelines and developer workflows.

INTEGRATION WITH UV ECOSYSTEM

The uv python command is seamlessly integrated into the broader uv ecosystem. This means you can use uv to install packages into Python environments managed by uv python, providing a cohesive and high-performance experience for your entire Python development setup.

HISTORY

uv was developed by Astral, the creators of the popular Rust-based linter and formatter Ruff. It was publicly announced in early 2024, aiming to address the performance shortcomings of existing Python packaging and environment management tools. The uv python subcommand was introduced to further consolidate Python tooling, allowing developers to manage both Python interpreters and packages with a single, highly optimized utility.

SEE ALSO

pip(1), venv(1), pyenv(1), conda(1), uv(1)

Copied to clipboard