Touch-ups to the Python install guide (#11116)

This commit is contained in:
Zanie Blue 2025-01-30 13:56:53 -06:00 committed by GitHub
parent 80d485d32a
commit e0a19be825
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 23 additions and 19 deletions

View file

@ -184,6 +184,8 @@ To exclude downloads and only show installed Python versions:
$ uv python list --only-installed $ uv python list --only-installed
``` ```
See the [`uv python list`](../reference/cli.md#uv-python-list) reference for more details.
## Finding a Python executable ## Finding a Python executable
To find a Python executable, use the `uv python find` command: To find a Python executable, use the `uv python find` command:

View file

@ -9,13 +9,8 @@ description:
If Python is already installed on your system, uv will If Python is already installed on your system, uv will
[detect and use](#using-existing-python-versions) it without configuration. However, uv can also [detect and use](#using-existing-python-versions) it without configuration. However, uv can also
install and manage Python versions for you. 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.
!!! tip
uv will [automatically fetch Python versions](#automatic-python-downloads) as needed — you don't need to install Python to get started.
<!-- TODO(zanieb): I don't love this heading. -->
## Getting started ## Getting started
@ -25,12 +20,9 @@ To install the latest Python version:
$ uv python install $ uv python install
``` ```
This will install a uv-managed Python version even if there is already a Python installation on your
system. If you've previously installed Python with uv, a new version will not be installed.
!!! note !!! note
Python does not publish official distributable binaries. As such, uv uses distributions from 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. 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.
Once Python is installed, it will be used by `uv` commands automatically. Once Python is installed, it will be used by `uv` commands automatically.
@ -67,6 +59,18 @@ $ uv python install pypy@3.10
See the [`python install`](../concepts/python-versions.md#installing-a-python-version) documentation See the [`python install`](../concepts/python-versions.md#installing-a-python-version) documentation
for more details. for more details.
## 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.
## Viewing Python installations ## Viewing Python installations
To view available and installed Python versions: To view available and installed Python versions:
@ -78,21 +82,19 @@ $ uv python list
See the [`python list`](../concepts/python-versions.md#viewing-available-python-versions) See the [`python list`](../concepts/python-versions.md#viewing-available-python-versions)
documentation for more details. documentation for more details.
<!--TODO(zanieb): The above should probably link to a CLI reference and that content should be moved out of that file -->
## Automatic Python downloads ## Automatic Python downloads
Note that Python does not need to be explicitly installed to use uv. By default, uv will Python does not need to be explicitly installed to use uv. By default, uv will automatically
automatically download Python versions when they are required. For example, the following would download Python versions when they are required. For example, the following would download Python
download Python 3.12 if it was not installed: 3.12 if it was not installed:
```console ```console
$ uv run --python 3.12 python -c "print('hello world')" $ uvx python@3.12 -c "print('hello world')"
``` ```
Even if a specific Python version is not requested, uv will download the latest version on demand. Even if a specific Python version is not requested, uv will download the latest version on demand.
For example, the following will create a new virtual environment and download a managed Python For example, if there are no Python versions on your system, the following will install Python
version if Python is not found: before creating a new virtual environment:
```console ```console
$ uv venv $ uv venv