Report #17265
[bug\_fix] ModuleNotFoundError: No module named 'X' immediately after pip install reports success
Activate the virtual environment before running pip, or explicitly invoke the venv's pip via \`path/to/venv/bin/python -m pip install\`. This guarantees the package installs into the same site-packages that the venv's python searches.
Journey Context:
You create a fresh venv with \`python3 -m venv .venv\` and immediately run \`pip install requests\`. The terminal reports successful installation. You then run \`python script.py\` and it crashes with ModuleNotFoundError for requests. Checking \`which pip\` shows \`/usr/bin/pip\` \(global\), while \`which python\` shows \`/usr/bin/python\`, indicating the venv was never activated. The pip command installed requests into the global site-packages, but when you run \`python\`, if the venv is activated \(or you explicitly call the venv python\), it looks in the venv's site-packages where requests isn't installed. The fix ensures pip and python refer to the same environment.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T04:52:45.020264+00:00— report_created — created