2025-01-16 04:12:55 +08:00
---
title: Installing and managing Python
description:
A guide to using uv to install Python, including requesting specific versions, automatic
installation, viewing installed versions, and more.
---
2024-07-02 12:44:45 -04:00
# Installing Python
2024-07-09 21:05:59 -04:00
2024-08-02 15:58:31 +02:00
If Python is already installed on your system, uv will
2025-01-29 13:41:18 -06:00
[detect and use ](#using-existing-python-versions ) it without configuration. However, uv can also
2025-01-30 13:56:53 -06:00
install and manage Python versions. uv [automatically installs ](#automatic-python-downloads ) missing
Python versions as needed — you don't need to install Python to get started.
2024-08-03 08:41:33 -05:00
## Getting started
2024-07-22 13:15:11 -04:00
To install the latest Python version:
2024-07-09 21:05:59 -04:00
``` console
$ uv python install
```
2024-07-22 13:15:11 -04:00
!!! note
2025-01-30 13:56:53 -06:00
Python does not publish official distributable binaries. As such, uv uses distributions from the Astral [`python-build-standalone` ](https://github.com/astral-sh/python-build-standalone ) project. See the [Python distributions ](../concepts/python-versions.md#managed-python-distributions ) documentation for more details.
2024-07-22 13:15:11 -04:00
Once Python is installed, it will be used by `uv` commands automatically.
2024-07-09 21:05:59 -04:00
2024-08-03 08:41:33 -05:00
!!! important
When Python is installed by uv, it will not be available globally (i.e. via the `python` command).
2024-12-19 16:07:46 -06:00
Support for this feature is in _ preview _ . See [Installing Python executables ](../concepts/python-versions.md#installing-python-executables )
for details.
You can still use
2024-08-03 08:41:33 -05:00
[`uv run` ](../guides/scripts.md#using-different-python-versions ) or
[create and activate a virtual environment ](../pip/environments.md ) to use `python` directly.
2024-07-09 21:05:59 -04:00
## Installing a specific version
To install a specific Python version:
``` console
$ uv python install 3.12
```
2024-08-03 08:41:33 -05:00
To install multiple Python versions:
``` console
$ uv python install 3.11 3.12
```
2025-03-13 16:42:10 -07:00
To install an alternative Python implementation, e.g., PyPy:
2024-08-03 08:41:33 -05:00
2024-09-01 01:04:19 +02:00
``` console
2024-11-06 00:13:58 +02:00
$ uv python install pypy@3.10
2024-08-03 08:41:33 -05:00
```
2024-07-30 18:17:58 -04:00
See the [`python install` ](../concepts/python-versions.md#installing-a-python-version ) documentation
for more details.
2024-07-09 21:05:59 -04:00
2025-01-30 13:56:53 -06:00
## Reinstalling Python
To reinstall uv-managed Python versions, use `--reinstall` , e.g.:
``` console
$ uv python install --reinstall
```
This will reinstall all previously installed Python versions. Improvements are constantly being
added to the Python distributions, so reinstalling may resolve bugs even if the Python version does
not change.
2024-07-09 21:05:59 -04:00
## Viewing Python installations
To view available and installed Python versions:
``` console
$ uv python list
```
2024-07-30 18:17:58 -04:00
See the [`python list` ](../concepts/python-versions.md#viewing-available-python-versions )
documentation for more details.
2024-07-10 11:37:53 -04:00
2024-07-09 21:05:59 -04:00
## Automatic Python downloads
2025-01-30 13:56:53 -06:00
Python does not need to be explicitly installed to use uv. By default, uv will automatically
download Python versions when they are required. For example, the following would download Python
3.12 if it was not installed:
2024-07-09 21:05:59 -04:00
``` console
2025-01-30 13:56:53 -06:00
$ uvx python@3.12 -c "print('hello world')"
2024-07-09 21:05:59 -04:00
```
2024-07-30 18:17:58 -04:00
Even if a specific Python version is not requested, uv will download the latest version on demand.
2025-01-30 13:56:53 -06:00
For example, if there are no Python versions on your system, the following will install Python
before creating a new virtual environment:
2024-07-09 21:05:59 -04:00
``` console
2024-07-24 18:10:33 -04:00
$ uv venv
2024-07-09 21:05:59 -04:00
```
2024-08-03 08:41:33 -05:00
!!! tip
Automatic Python downloads can be [easily disabled ](../concepts/python-versions.md#disabling-automatic-python-downloads ) if you want more control over when Python is downloaded.
2024-07-17 10:28:55 -04:00
<!-- TODO(zanieb): Restore when Python shim management is added
2024-07-09 21:05:59 -04:00
Note that when an automatic Python installation occurs, the `python` command will not be added to the shell. Use `uv python install-shim` to ensure the `python` shim is installed.
2024-07-17 10:28:55 -04:00
-->
2024-07-09 21:05:59 -04:00
2025-01-29 13:04:11 -06:00
## Using existing Python versions
2024-07-09 21:05:59 -04:00
2024-08-03 08:41:33 -05:00
uv will use existing Python installations if present on your system. There is no configuration
necessary for this behavior: uv will use the system Python if it satisfies the requirements of the
2024-08-15 02:27:22 +02:00
command invocation. See the
[Python discovery ](../concepts/python-versions.md#discovery-of-python-versions ) documentation for
details.
2024-07-10 11:37:53 -04:00
2024-07-30 18:17:58 -04:00
To force uv to use the system Python, provide the `--python-preference only-system` option. See the
[Python version preference ](../concepts/python-versions.md#adjusting-python-version-preferences )
documentation for more details.
2024-08-03 08:41:33 -05:00
## Next steps
To learn more about `uv python` , see the [Python version concept ](../concepts/python-versions.md )
page and the [command reference ](../reference/cli.md#uv-python ).
Or, read on to learn how to [run scripts ](./scripts.md ) and invoke Python with uv.