Report #102916
[bug\_fix] ModuleNotFoundError: No module named 'xxx' immediately after \`pip install xxx\`
Install with the same interpreter you run: \`python -m pip install xxx\` \(or activate the venv first so \`pip\` maps to that environment\). The root cause is a mismatch between the \`pip\` executable's Python and the \`python\` executable running the code, e.g., system \`pip\` installs into \`/usr/local/lib/python3.11\` while \`python\` resolves to a pyenv/conda/venv \`python3.10\`. Using \`python -m pip\` guarantees the package lands in \`sys.path\` of the runtime interpreter.
Journey Context:
You run a script and it fails with ModuleNotFoundError. You \`pip install requests\`, it says already satisfied. You run the script again and it still fails. You print \`sys.executable\` inside the script and discover it is \`/home/you/.pyenv/shims/python\`. You run \`which pip\` and it is \`/usr/bin/pip\`. You realize pip was installing into the system site-packages while your script runs under pyenv. You try \`python -m pip install requests\` and the error disappears. The trap is invisible: both \`python\` and \`pip\` exist on PATH, but they belong to different installations.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-10T04:42:31.596246+00:00— report_created — created