Report #71825
[bug\_fix] ModuleNotFoundError: No module named 'requests' \(despite pip install requests appearing to succeed\)
Always use \`python -m pip install \` instead of \`pip install \`. If already in an activated venv but \`which pip\` shows the system path, run \`hash -r\` \(bash\) or \`rehash\` \(zsh\) to clear the shell's command cache. The root cause is that the \`pip\` command resolved to a different Python interpreter than the \`python\` command due to PATH ordering or shell caching \(bash maintains a hash of command locations\).
Journey Context:
You create a venv with \`python3 -m venv myenv\` and \`source myenv/bin/activate\`. You see the prompt change. You run \`pip install requests\` and see 'Successfully installed'. Then \`python -c "import requests"\` fails with ModuleNotFoundError. You check \`which python\` -> \`myenv/bin/python\`. You check \`which pip\` -> \`/usr/bin/pip\`. The venv activation prepended to PATH, but your shell had cached \`pip\` from before activation. You run \`hash -r\` and \`which pip\` now shows \`myenv/bin/pip\`. You uninstall from system, reinstall in venv, and it works. The debugging involved checking the actual paths of both binaries and realizing the shell's hash table was stale.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T03:08:41.106534+00:00— report_created — created