uv/docs/guides/install-python.md
konsti db371560bc
Use prettier to format the documentation (#5708)
To enforce the 100 character line limit in markdown files introduced in
https://github.com/astral-sh/uv/pull/5635, and to automate the
formatting of markdown files, i've added prettier and formatted our
markdown files with it.

I've excluded the changelog and the generated references documentation
from this for having too many changes, but we can also include them.

I'm not particular on which style we use. My main motivations are
(major) not having to reflow markdown files myself anymore and (minor)
consistence between all markdown files. I've chosen prettier for similar
reason as we chose black, it's a single good style that's automated and
shared in the community. I do prefer prettier's style of not breaking
inside of a link name though.

This PR is in two parts, the first adds prettier to CI and documents
using it, while the second actually formats the docs. When merge
conflicts arise, we can drop the last commit and regenerate it with `npx
prettier --prose-wrap always --write BENCHMARKS.md CONTRIBUTING.md
README.md STYLE.md docs/*.md docs/concepts/**/*.md docs/guides/**/*.md
docs/pip/**/*.md`.

---------

Co-authored-by: Zanie Blue <contact@zanie.dev>
2024-08-02 08:58:31 -05:00

3.5 KiB

Installing Python

If Python is already installed on your system, uv will detect and use it without configuration. However, uv can also install and manage Python versions for you.

!!! tip

uv will [automatically fetch Python versions](#automatic-python-downloads) as needed — you don't need to install Python to get started.

To install the latest Python version:

$ uv python install

This will install a uv managed Python version even if there is already a Python installation on your system.

!!! note

Python does not publish official distributable binaries so uv uses third-party distributions from the [`python-build-standalone`](https://github.com/indygreg/python-build-standalone) project. The project is partially maintained by the uv maintainers and is used by many other Python projects. See the [Python distributions](../concepts/python-versions.md#python-distributions) documentation for more details.

Once Python is installed, it will be used by uv commands automatically.

Installing a specific version

To install a specific Python version:

$ uv python install 3.12

See the python install documentation for more details.

Viewing Python installations

To view available and installed Python versions:

$ uv python list

See the python list documentation for more details.

Automatic Python downloads

Note that 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:

$ uv run --python 3.12 python -c 'print("hello world")'

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 version if Python is not found:

$ uv venv

Using an existing Python installation

uv will also use an existing Python installation if already 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 command invocation. See the Python discovery documentation for details.

To force uv to use the system Python, provide the --python-preference only-system option. See the Python version preference documentation for more details.