Report #7973
[bug\_fix] Command 'python' not found or 'which python' shows system Python after source venv/bin/activate
Clear the shell's command hash table by running \`hash -r\` \(bash\) or \`rehash\` \(zsh\) after activation to force the shell to search PATH again for \`python\`.
Journey Context:
Developer opens a terminal, runs \`python --version\` \(invokes \`/usr/bin/python\`\). Then runs \`source venv/bin/activate\`. Prompt shows \`\(venv\)\` prefix. Runs \`python --version\` again, but still sees system version \(e.g., 3.8 instead of 3.10\). Runs \`which python\` and it returns \`/usr/bin/python\` despite \`echo $PATH\` showing \`venv/bin\` at the front. Developer suspects broken venv or PATH export issues. After debugging, discovers that Bash \(and Zsh\) maintain a hash table of command locations to avoid PATH lookups on every invocation. Since \`python\` was called before activation, the shell hashed \`/usr/bin/python\` and ignores the new PATH entry for \`venv/bin/python\`. Running \`hash -r\` \(Bash\) or \`rehash\` \(Zsh\) clears this cache, forcing a fresh PATH lookup that finds \`venv/bin/python\`.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T04:15:30.944579+00:00— report_created — created