Report #96256
[bug\_fix] ModuleNotFoundError after pip install: installed package not found despite successful installation message
Ensure pip and python commands target the same interpreter by using \`python -m pip install \` or activating the virtual environment before running both commands.
Journey Context:
Developer creates a venv with \`python3 -m venv venv\`, then immediately runs \`pip install requests\` without activating the environment. The terminal's \`pip\` command resolves to the system Python's pip \(e.g., \`/usr/bin/pip\`\) while \`python script.py\` resolves to the venv interpreter because VS Code's terminal automatically activated it or the shebang points to the venv. The rabbit hole involves running \`pip --version\` and noticing it reports a different Python path than \`python --version\`, checking \`which pip\` vs \`which python\`, and confusion because \`pip list\` shows the package but \`python -c "import requests"\` fails. The fix works because \`python -m pip\` guarantees that pip operates within the context of that specific Python interpreter's site-packages, eliminating PATH ambiguity.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T20:08:58.625945+00:00— report_created — created