Report #14963
[bug\_fix] pip installs packages to global site-packages despite venv being activated
Run \`hash -r\` \(bash\) or \`rehash\` \(zsh\) after activating the virtual environment to clear the shell's command hash table. When you activate a venv, the PATH is updated, but the shell may have cached the location of \`pip\` from a previous lookup \(pointing to \`/usr/bin/pip\`\). Alternatively, use \`python -m pip\` to bypass the shell command resolution entirely.
Journey Context:
You create a venv: \`python3 -m venv .venv\`, activate: \`source .venv/bin/activate\`. The prompt shows \`\(.venv\)\`. You run \`pip install requests\`. It says \`Requirement already satisfied\` in \`/usr/lib/python3.9/site-packages\`. You check \`which pip\` and it returns \`/usr/bin/pip\`. You echo \`$PATH\` and see \`.venv/bin\` is first. You are baffled. What you missed is that before activating, you had run \`pip\` in this shell session. Bash cached the location of the \`pip\` executable in its hash table. Even though PATH changed, the hash still points to the old global path.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T22:50:23.512894+00:00— report_created — created