2.8 KiB
Installing Python
If Python is already installed, uv will detect and use it without configuration. However, uv can also install and manage Python versions.
To install Python:
$ uv python install
This will install a uv-managed Python version even if there is already a Python installation on the system.
Once Python is installed, it will be used by uv
commands.
Installing a specific version
To install a specific Python version:
$ uv python install 3.12
See the Python versions 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 one hasn't been installed yet:
$ uv venv --python-preference only-managed
Using an existing Python installation
uv will also use an existing Python installation if already present on the system. There's 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.