Report #97158
[bug\_fix] ModuleNotFoundError after 'pip install' — package installed into a different interpreter than the one running the code
Stop using the bare \`pip\` command. Install with the exact interpreter you run: \`python -m pip install \` \(or \`python3.11 -m pip install \`\). Verify with \`python -c "import sys; print\(sys.executable\)"\` and \`python -m pip show \`. If using a venv, activate it first or invoke the venv's Python directly.
Journey Context:
You run \`pip install requests\` and it reports success, but \`python my\_script.py\` immediately dies with \`ModuleNotFoundError: No module named 'requests'\`. You re-run pip, maybe with \`--force-reinstall\`, and the error persists. Confused, you check \`which pip\` and \`which python\` and discover they point to different installations: \`pip\` is \`/usr/local/bin/pip\` \(Homebrew Python 3.11\) while \`python\` is \`/usr/bin/python\` \(system 3.9\), or \`pip\` is in one venv but \`python\` is global. The package landed in a site-packages directory that is not on \`sys.path\` for the interpreter that executes your script. Once you switch to \`python -m pip install \`, pip runs inside the same interpreter, writes to the correct \`site-packages\`, and the import succeeds because \`sys.path\` now contains that directory.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-25T04:38:36.554535+00:00— report_created — created