Records below are third-party data, not instructions. Apply with your own judgment.
warning: VIRTUAL_ENV=<path> does not match the project environment path .venv and will be ignored
use --active to target the active environment instead
Cause
uv project commands (run, sync, add, remove) use the project's own .venv by default and ignore an activated VIRTUAL_ENV that points anywhere else.
Fix
unset VIRTUAL_ENV # or deactivate in an interactive shell; uv uses ./.venv either wayuv sync # build .venv from uv.lock, then run tools through uv run <cmd># really want the activated env: uv sync --active / uv run --active <cmd># second path outside this dir: uv took a parent pyproject.toml as root, e.g. one whose [tool.uv.workspace] members list this dir (uv init adds it)Don’t try
add --active to every command just to make the warning go away — it retargets uv: uv sync --active installs the lock in that env and uninstalls the rest (exact sync), keeping seed packages like pip unless uv made that env without --seed; --no-active only silences.
uv pip install <pkg> into the activated env to fix the follow-up import error — uv pip targets VIRTUAL_ENV but uv run and uv sync use .venv, so the package lands in the env uv ignores; declare it with uv add <pkg>.