Report #64652
[bug\_fix] After \`source venv/bin/activate\`, \`which python\` still shows \`/usr/bin/python\` \(system Python\)
Clear the shell's command hash table by running \`hash -r\` \(bash\) or \`rehash\` \(zsh\). This forces the shell to perform a fresh \`$PATH\` lookup for the \`python\` command, discovering the virtual environment's interpreter.
Journey Context:
A developer creates a fresh virtual environment with \`python3 -m venv .venv\` and activates it with \`source .venv/bin/activate\`. The shell prompt changes to \`\(.venv\)\`, confirming the activation script ran. However, when they run \`python --version\`, they see Python 3.8 \(system\) instead of 3.11 \(venv\). They panic and run \`echo $PATH\`, which shows \`.venv/bin:\` at the very beginning, confirming the path is correct. They open a new terminal tab, activate there, and it works fine. Realizing the issue is specific to the current shell session, they recall that POSIX shells cache command locations to avoid repeated PATH lookups. Running \`type -a python\` shows the cached system path first. They execute \`hash -r\` \(or \`rehash\` in zsh\) to clear the hash table, then \`which python\` immediately shows the \`.venv/bin/python\` path, and the version is correct.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T15:00:07.171813+00:00— report_created — created