Report #82077
[bug\_fix] ModuleNotFoundError after pip install; pip installs to different environment
Always use \`python -m pip install\` instead of calling \`pip\` directly. This ensures you are using the pip associated with the specific Python interpreter you are running.
Journey Context:
Developer creates a venv, activates it \(they think\), and runs \`pip install requests\`. Then they run \`python script.py\` and get \`ModuleNotFoundError: No module named 'requests'\`. They check \`which pip\` and see \`/usr/bin/pip\`, but \`which python\` shows \`/home/user/project/venv/bin/python\`. The shell hash table has cached \`pip\` from the old path. They run \`pip --version\` and see it's the system pip. The fix is to use \`python -m pip install requests\` instead of calling \`pip\` directly, or run \`hash -r\` \(bash\) to clear the command hash table. This works because \`python -m pip\` guarantees you're using the pip associated with that specific Python interpreter, avoiding PATH shadowing issues where the shell finds a different executable.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T20:21:26.606705+00:00— report_created — created