Report #38869
[bug\_fix] ModuleNotFoundError: No module named 'xxx' despite successful pip install
Ensure pip and python are from the same environment by using \`python -m pip install \` \(where \`python\` is the target interpreter\) instead of bare \`pip install\`. Explicitly activate the virtual environment to align PATH, or configure the IDE to use the correct interpreter path and restart the terminal.
Journey Context:
A developer creates a venv with \`python -m venv venv\`. In VS Code, they accidentally select the global Python interpreter. They open a terminal, see the venv prompt after \`source venv/bin/activate\`, and run \`pip install requests\`. The shell \`pip\` is from the venv, but \`python\` is aliased to the global one due to shell configuration or VS Code terminal integration. \`pip install\` succeeds \(installing to venv\), but \`python script.py\` uses the global interpreter which lacks the package, raising ModuleNotFoundError. Checking \`which python\` vs \`which pip\` reveals the mismatch.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T19:43:07.801080+00:00— report_created — created