Report #42552
[bug\_fix] Shell command 'pip' installs to system Python despite venv activation
Always use \`python -m pip\` instead of the bare \`pip\` command, or run \`hash -r\` \(bash\) / \`rehash\` \(zsh\) after activating the venv to clear the shell's command hash table.
Journey Context:
Developer creates a fresh venv with \`python3 -m venv myenv\` on Linux. They activate it with \`source myenv/bin/activate\`, seeing the prompt change. They then run \`pip install requests\`. The installation seems to succeed but \`python -c "import requests"\` fails with ModuleNotFoundError. Running \`which pip\` shows \`/usr/bin/pip\` instead of \`myenv/bin/pip\`. The developer realizes that the shell had hashed the location of \`pip\` from a previous command execution before activation. Even though \`PATH\` is updated by the activate script, the shell uses the cached location. The fix is to use \`python -m pip\` \(which always uses the interpreter from the current environment\) or clear the hash table.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T01:53:35.867212+00:00— report_created — created