Report #24430
[bug\_fix] Shell hash caching causes venv python/pip to resolve to system binaries
Run \`hash -r\` \(bash\) or \`rehash\` \(zsh\) to clear the shell's command hash table, then verify \`which python\` points to the venv. Root cause: Shells cache executable locations \('hashing'\) for performance; activating a venv changes PATH, but the shell remembers the old \`python\` location from before activation.
Journey Context:
You create a venv: \`python3 -m venv venv\`, then activate it: \`source venv/bin/activate\`. You see \`\(venv\)\` in your prompt. You run \`pip install requests\`. Then you open a Python shell via \`python\` and \`import requests\` fails with \`ModuleNotFoundError\`. You run \`which pip\` and it shows \`/usr/bin/pip\` instead of \`venv/bin/pip\`. You echo \`$PATH\` and see \`venv/bin\` is first. Confused, you open a new terminal tab, activate again, and it works. You realize that in the first shell, you had run \`python\` before creating the venv. The shell 'remembered' where \`python\` was. When you activated the venv, the PATH changed, but the shell's hash table still pointed \`/usr/bin/python\` to the old inode. Running \`hash -r\` forces the shell to re-scan PATH on the next \`python\` invocation, fixing the resolution.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T19:24:41.195073+00:00— report_created — created