Summary
While waiting for #18214 , I have been using this trick to tell uv sync where to put the Python environment
uv run --env-file=.env -- uv sync
where the .env file contains a line analoguous to UV_PROJECT_ENVIRONMENT=C:/venvs/uv-mre.
As of lately, this does not work anymore: the Python environment is created in .venv nonetheless. Possibly the same as #19540 .
Minimal reproducible example
Create a minimal pyproject.toml
[project]
name = "uv-mre"
version = "0.1.0"
then run the following with PowerShell
PS>"UV_PROJECT_ENVIRONMENT=C:/venvs/uv-mre" > .env
PS>uv run --verbose --env-file=.env -- python -c "import os; print(os.environ['UV_PROJECT_ENVIRONMENT'])"
I obtained
DEBUG Found workspace root: `C:\cache\uv-mre`
DEBUG Adding root workspace member: `C:\cache\uv-mre`
DEBUG Skipping `pyproject.toml` in `C:\cache\uv-mre` (no `[tool]` section)
DEBUG Searching for user configuration in: `C:\Users\peronian\AppData\Roaming\uv\uv.toml`
DEBUG uv 0.11.20 (9252ba6b5 2026-06-10 x86_64-pc-windows-msvc)
DEBUG Read environment file at: `.env`
DEBUG Found project root: `C:\cache\uv-mre`
DEBUG No workspace root found, using project root
DEBUG Discovered project `uv-mre` at: C:\cache\uv-mre
DEBUG No Python version file found in workspace: C:\cache\uv-mre
DEBUG Checking for Python environment at: `.venv`
DEBUG Searching for default Python interpreter in managed installations, search path, or registry
DEBUG Searching for managed installations at `C:\Users\peronian\AppData\Roaming\uv\python`
DEBUG Found managed installation `cpython-3.14.5-windows-x86_64-none`
DEBUG Found `cpython-3.14.5-windows-x86_64-none` at `C:\Users\peronian\AppData\Roaming\uv\python\cpython-3.14-windows-x86_64-none\python.exe` (managed installations)
Using CPython 3.14.5
Creating virtual environment at: .venv
DEBUG Using base executable for virtual environment: C:\Users\peronian\AppData\Roaming\uv\python\cpython-3.14-windows-x86_64-none\python.exe
DEBUG Using junction C:\Users\peronian\AppData\Roaming\uv\python\cpython-3.14-windows-x86_64-none instead of base Python path: C:\Users\peronian\AppData\Roaming\uv\python\cpython-3.14-windows-x86_64-none\python.exe
warning: No `requires-python` value found in the workspace. Defaulting to `>=3.14`.
DEBUG Using request connect timeout of 10s and read timeout of 30s
DEBUG Found static `requires-dist` for: C:\cache\uv-mre\
DEBUG Existing `uv.lock` satisfies workspace requirements
Resolved 1 package in 2ms
DEBUG Using request connect timeout of 10s and read timeout of 30s
Checked in 0.01ms
DEBUG Using Python 3.14.5 interpreter at: C:\cache\uv-mre\.venv\Scripts\python.exe
DEBUG Running `python -c import os; print(os.environ['UV_PROJECT_ENVIRONMENT'])`
C:/venvs/uv-mre
DEBUG Command exited with code: 0
In short
uv run finds the .env file and sets the UV_PROJECT_ENVIRONMENT environment variable correctly.
- The virtual environment is created nonetheless in
.venv, and not in the folder specified by UV_PROJECT_ENVIRONMENT.
Platform
Wndows 11 x86_64
Version
uv 0.11.20
Python version
Python 3.14.5
Summary
While waiting for #18214 , I have been using this trick to tell
uv syncwhere to put the Python environmentwhere the
.envfile contains a line analoguous toUV_PROJECT_ENVIRONMENT=C:/venvs/uv-mre.As of lately, this does not work anymore: the Python environment is created in
.venvnonetheless.Possibly the same as #19540 .Minimal reproducible example
Create a minimal
pyproject.tomlthen run the following with PowerShell
I obtained
In short
uv runfinds the.envfile and sets theUV_PROJECT_ENVIRONMENTenvironment variable correctly..venv, and not in the folder specified byUV_PROJECT_ENVIRONMENT.Platform
Wndows 11 x86_64
Version
uv 0.11.20
Python version
Python 3.14.5