diff --git a/docs/concepts/python-versions.md b/docs/concepts/python-versions.md index 93706cd4da29..2d91650b6b7c 100644 --- a/docs/concepts/python-versions.md +++ b/docs/concepts/python-versions.md @@ -134,20 +134,6 @@ To exclude downloads and only show installed Python versions: $ uv python list --only-installed ``` -## Discovery of virtual environments - -Some uv commands may use a Python interpreter from a virtual environment. When searching for virtual -environments, uv prioritizes (in order): - -- The `VIRTUAL_ENV` environment variable. -- The `CONDA_PREFIX` environment variable. -- A `.venv` directory in the working directory. -- A `.venv` directory in any parent directory. - -After exhausting these possibilities, uv will either -[search for a Python installation](#discovery-of-python-versions) or exit with an error if the -command requires a virtual environment. - ## Discovery of Python versions When searching for a Python version, the following locations are checked: @@ -158,6 +144,12 @@ When searching for a Python version, the following locations are checked: - On Windows, the Python interpreter returned by `py --list-paths` that matches the requested version. +In some cases, uv allows using a Python version from a virtual environment. In this case, the +virtual environment's interpreter will be checked for compatibility with the request before +searching for an installation as described above. See the +[pip-compatible virtual environment discovery](../pip/environments.md#discovery-of-python-environments) +documentation for details. + When performing discovery, non-executable files will be ignored. Each discovered executable is queried for metadata to ensure it meets the [requested Python version](#requesting-a-version). If the query fails, the executable will be skipped. If the executable satisfies the request, it is used diff --git a/docs/pip/environments.md b/docs/pip/environments.md index 4a8a06549488..e6c21bfb77ec 100644 --- a/docs/pip/environments.md +++ b/docs/pip/environments.md @@ -107,18 +107,9 @@ will search for a virtual environment in the following order: If no virtual environment is found, uv will prompt the user to create one in the current directory via `uv venv`. -If the `--system` flag is included, uv will skip virtual environments and search for: - -- The Python interpreter available as `python3` on macOS and Linux, or `python.exe` on Windows. -- On Windows, the Python interpreter returned by `py --list-paths` that matches the requested - version. - -If a specific Python version is requested, e.g., `--python 3.7`, additional executable names are -included: - -- The Python interpreter available as, e.g., `python3.7` on macOS and Linux. - -When running a command that does not mutate the environment such as `uv pip compile`, uv does not -_require_ a virtual environment. Instead, it needs a Python toolchain to create ephemeral -environments. See the documentation on -[toolchain discovery](../concepts/python-versions.md#discovery-order) for details on discovery. +If the `--system` flag is included, uv will skip virtual environments search for an installed Python +version. Similarly, when running a command that does not mutate the environment such as +`uv pip compile`, uv does not _require_ a virtual environment — however, a Python interpreter is +still required. See the documentation on +[Python discovery](../concepts/python-versions.md#discovery-order) for details on the discovery of +installed Python versions.