What this thread does
The problem
Two questions are tangled together. Which tool should manage a Python environment today, and how do you stop an agent from running bare pip install or python against the wrong interpreter?
What the sources say
- An r/learnpython thread by GarlicHefty (13 October 2026) asked if uv is really the best way to create and manage virtual environments. Most commenters use uv. Reasons given: it installs the right Python version, keeps a lockfile (
uv.lock),uv runremoves the "did I activate the right venv" step, and resolution is faster on big dependency sets (one commenter said minutes versus seconds on a scientific stack; another disputed that pip is slow on their laptop). Others stay on venv and pip because it ships with Python and works withpyproject.toml; one dislikes typinguv run. Several suggested that the choice depends on the project: uv or Poetry when you manage dependencies and lockfiles, plain venv for small scripts, conda when you need non-Python system libraries, and Docker as a deployment layer, not a replacement. - uv's docs say
uv venvcreates.venv, anduv pip install/syncfind an environment in this order: an activeVIRTUAL_ENV, an active conda environment, then a.venvin the current or nearest parent directory.uv run/syncuse the project environment, with--activeopting intoVIRTUAL_ENV. By default uv ignores interpreters that are not in virtual environments, so it will not modify system Python;--systemopts in and the docs call it appropriate for CI and containerized environments. uv is Apache-2.0 or MIT, at your option. - On the agent side, an r/ClaudeCode post (March 2026) says the author could not get Claude to reliably create and use a fresh uv venv for each new git worktree, and kept corrupting a venv with editable installs that pointed at the wrong worktree. Two other low-scoring posts quote one-line rules they put in CLAUDE.md: "Always use uv run python. Never run python3 or python directly." and "use Astral UV not raw Python".
How to apply it
1. Pick one tool per project and write it down: for a new project with dependencies, uv init, uv add <pkg>, uv sync, commit pyproject.toml and uv.lock. 2. Put the rule in CLAUDE.md or AGENTS.md: run Python and tools through uv run, never bare pip install or python3. 3. With worktrees, give each its own .venv (uv sync inside it) and check uv run python -c "import sys; print(sys.prefix)". 4. If you stay on venv, activate it in the agent's shell or call .venv/bin/python directly, and say so in the rule. 5. Do not use --system on a developer machine.
Mistakes to check
- The agent starts a new shell and loses the activated venv;
uv runor an absolute.venv/bin/pythonpath avoids that. - Editable installs shared across worktrees.
- Switching an old project to uv without committing the lockfile.
Limits
I did not run these. The thread is opinion, not a benchmark, and the CLAUDE.md rules are quoted from low-scoring posts.
Primary source
Primary source: uv docs, Using Python environments (Astral) and the uv repository. Checked: uv venv creates .venv; uv pip install/sync look for an active VIRTUAL_ENV, then an active conda environment, then a .venv in the current or nearest parent directory; without --system uv ignores interpreters that are not in virtual environments, so system Python is not modified; the repository is Apache-2.0 or MIT, at your option. Small correction made above: the docs call --system appropriate for CI and containers rather than recommended. Not checked: the r/learnpython and r/ClaudeCode threads, the CLAUDE.md rule quotes and the speed claims.
Started from a post by @GarlicHefty, packaged by the editor. Original post