/errors/uv/no-virtual-environment-found
uv: error: No virtual environment found; run `uv venv` to create an environment, or pass `--system`
- tool
- uv
- exit code
- 2
- versions
- uv 0.5 – 0.12
- os
- any
error: No virtual environment found; run uv venv to create an environment, or pass --system to install into a non-virtual environment means a uv pip command that changes packages found no environment to change. uv looks for an activated environment (VIRTUAL_ENV), then for .venv in the current folder and its parents. It never installs into the system Python by default. Run uv venv first, or pass --system when the system interpreter is the target on purpose.
Reproduce it
uv pip sync and uv pip install share the same check:
echo "six==1.16.0" > requirements.txt
uv pip sync requirements.txtuv exits with code 2 for this error, not 1.
Fix
echo "six==1.16.0" > requirements.txt
uv venv -q --python 3.13
uv pip sync requirements.txt # installs into .venvRead-only commands such as uv pip list do not fail: without a virtual environment they report the interpreter they found (Using Python 3.x environment at: ...).
| Situation | Use |
|---|---|
| Local project with requirements.txt | uv venv, then uv pip install -r requirements.txt |
| Project with pyproject.toml | uv add / uv sync (manage .venv for you) |
| Docker image, install into system Python | uv pip install --system -r requirements.txt |
| Environment in another folder | uv pip install --python /path/to/venv PACKAGE |