Add document for specifying Python interpreter in tool installation and upgrade commands. (#11598)

<!--
Thank you for contributing to uv! To help us out with reviewing, please
consider the following:

- Does this pull request include a summary of the change? (See below.)
- Does this pull request include a descriptive title?
- Does this pull request include references to any relevant issues?
-->

## Summary
Just to add the section for installing and upgrading uv tool, specifying
the Python version, in the document.
Originally, it was planned to add a markdown block (header) for
representation, but it was felt to be a bit redundant, so it ended up
being like this.

close https://github.com/astral-sh/uv/issues/11536

## Test Plan
Run doc server with strict mode in local. (``mkdocs serve -f
mkdocs.public.yml --strict``)

![image](https://github.com/user-attachments/assets/9da66a8b-5423-4937-bc66-ea696ad1ab88)



<!-- How was it tested? -->

---------

Signed-off-by: FishAlchemist <48265002+FishAlchemist@users.noreply.github.com>
Co-authored-by: Zanie Blue <contact@zanie.dev>
This commit is contained in:
FishAlchemist 2025-02-19 01:45:58 +08:00 committed by GitHub
parent 3634a4d8e9
commit 555bf89b38
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -237,6 +237,33 @@ To instead upgrade all tools:
$ uv tool upgrade --all
```
## Requesting Python versions
By default, uv will use your default Python interpreter (the first it finds) when when running,
installing, or upgrading tools. You can specify the Python interpreter to use with the `--python`
option.
For example, to request a specific Python version when running a tool:
```console
$ uvx --python 3.10 ruff
```
Or, when installing a tool:
```console
$ uv tool install --python 3.10 ruff
```
Or, when upgrading a tool:
```console
$ uv tool upgrade --python 3.10 ruff
```
For more details on requesting Python versions, see the
[Python version](../concepts/python-versions.md#requesting-a-version) concept page..
## Next steps
To learn more about managing tools with uv, see the [Tools concept](../concepts/tools.md) page and