Synopsis
Description
Download and install Python versions. Supports CPython and PyPy. CPython distributions are downloaded from the Astralpython-build-standalone project. PyPy distributions are downloaded from python.org. The available Python versions are bundled with each uv release. To install new Python versions, you may need to upgrade uv.
Python versions are installed into the uv Python directory, which can be retrieved with uv python dir.
By default, Python executables are added to a directory on the path with a minor version suffix, e.g., python3.13. To install python3 and python, use the --default flag. Use uv python dir --bin to see the target directory.
Multiple Python versions may be requested.
See uv help python to view supported request formats.
Arguments
[TARGETS]...
The Python version(s) to install.
If not provided, the requested Python version(s) will be read from:
- The
UV_PYTHONenvironment variable .python-versionsor.python-versionfiles- If none of the above are present, uv will check if it has installed any Python versions
- If not, it will install the latest stable version of Python
uv help python to view supported request formats.
Environment variable: UV_PYTHON
Options
Installation Directory
-d, --install-dir <INSTALL_DIR>
The directory to store the Python installation in.
If provided, UV_PYTHON_INSTALL_DIR will need to be set for subsequent operations for uv to discover the Python installation.
See uv python dir to view the current Python installation directory.
- Type: Path
- Default:
~/.local/share/uv/python - Environment variable:
UV_PYTHON_INSTALL_DIR
Executable Installation
--bin
Install a Python executable into the bin directory.
This is the default behavior. If this flag is provided explicitly, uv will error if the executable cannot be installed.
This can also be set with UV_PYTHON_INSTALL_BIN=1.
See UV_PYTHON_BIN_DIR to customize the target directory.
- Conflicts with:
--no-bin
--no-bin
Do not install a Python executable into the bin directory.
This can also be set with UV_PYTHON_INSTALL_BIN=0.
- Conflicts with:
--bin,--default
Registry (Windows)
--registry
Register the Python installation in the Windows registry.
This is the default behavior on Windows. If this flag is provided explicitly, uv will error if the registry entry cannot be created.
This can also be set with UV_PYTHON_INSTALL_REGISTRY=1.
- Conflicts with:
--no-registry
--no-registry
Do not register the Python installation in the Windows registry.
This can also be set with UV_PYTHON_INSTALL_REGISTRY=0.
- Conflicts with:
--registry
Installation Behavior
-r, --reinstall
Reinstall the requested Python version, if it’s already installed.
By default, uv will exit successfully if the version is already installed.
-f, --force
Replace existing Python executables during installation.
By default, uv will refuse to replace executables that it does not manage.
Implies --reinstall.
-U, --upgrade
Upgrade existing Python installations to the latest patch version.
By default, uv will not upgrade already-installed Python versions to newer patch releases. With --upgrade, uv will upgrade to the latest available patch version for the specified minor version(s).
If the requested versions are not yet installed, uv will install them.
This option is only supported for minor version requests, e.g., 3.12; uv will exit with an error if a patch version, e.g., 3.12.2, is requested.
--default
Use as the default Python version.
By default, only a python{major}.{minor} executable is installed, e.g., python3.10. When the --default flag is used, python{major}, e.g., python3, and python executables are also installed.
Alternative Python variants will still include their tag. For example, installing 3.13+freethreaded with --default will include python3t and pythont instead of python3 and python.
If multiple Python versions are requested, uv will exit with an error.
- Conflicts with:
--no-bin
Mirror URLs
--mirror <MIRROR>
Set the URL to use as the source for downloading Python installations.
The provided URL will replace https://github.com/astral-sh/python-build-standalone/releases/download in, e.g., https://github.com/astral-sh/python-build-standalone/releases/download/20240713/cpython-3.12.4%2B20240713-aarch64-apple-darwin-install_only.tar.gz.
Distributions can be read from a local directory by using the file:// URL scheme.
- Type: URL
--pypy-mirror <PYPY_MIRROR>
Set the URL to use as the source for downloading PyPy installations.
The provided URL will replace https://downloads.python.org/pypy in, e.g., https://downloads.python.org/pypy/pypy3.8-v7.3.7-osx64.tar.bz2.
Distributions can be read from a local directory by using the file:// URL scheme.
- Type: URL
--python-downloads-json-url <PYTHON_DOWNLOADS_JSON_URL>
URL pointing to JSON of custom Python installations.
- Type: String
Bytecode Compilation
--compile-bytecode
Compile Python’s standard library to bytecode after installation.
By default, uv does not compile Python (.py) files to bytecode (__pycache__/*.pyc); instead, compilation is performed lazily the first time a module is imported. For use-cases in which start time is important, such as CLI applications and Docker containers, this option can be enabled to trade longer installation times and some additional disk space for faster start times.
When enabled, uv will process the Python version’s stdlib directory. It will ignore any compilation errors.
- Aliases:
--compile - Environment variable:
UV_COMPILE_BYTECODE - Conflicts with:
--no-compile-bytecode
--no-compile-bytecode
Do not compile Python’s standard library to bytecode.
- Aliases:
--no-compile - Conflicts with:
--compile-bytecode
Version Request Formats
The following Python version request formats are supported:<version>e.g.3,3.12,3.12.3<version-specifier>e.g.>=3.12,<3.13<version><short-variant>e.g.,3.13t,3.12.0d<version>+<variant>e.g.,3.13+freethreaded,3.12.0+debug<implementation>e.g.cpythonorcp<implementation>@<version>e.g.[email protected]<implementation><version>e.g.cpython3.12orcp312<implementation><version-specifier>e.g.cpython>=3.12,<3.13<implementation>-<version>-<os>-<arch>-<libc>e.g.cpython-3.12.3-macos-aarch64-none
Examples
Install the latest Python version
Install a specific minor version
Install a specific patch version
Install multiple versions
Install PyPy
Install with default executables
python3.12, python3, and python executables.
Install from a custom mirror
Install with bytecode compilation
Reinstall an existing version
Upgrade to latest patch version
Install without executables
Force replace existing executables
Output Format
Successful Installation
Already Installed
With —reinstall
Multiple Versions
See Also
uv python list- List available Python installationsuv python uninstall- Uninstall Python versionsuv python find- Find a Python installationuv python pin- Pin to a specific Python version