Report #90797
[bug\_fix] ModuleNotFoundError: No module named 'requests'
Use \`python -m pip install requests\` or activate the virtual environment before installing. Root cause: The \`pip\` command resolves to a different Python installation's site-packages \(often system Python\) than the \`python\` executable being used to run the script \(often a venv\), because PATH prioritizes the system pip or the venv is not activated.
Journey Context:
A developer creates a fresh venv with \`python -m venv venv\` on their Linux workstation. They immediately run \`pip install requests\` which reports successful installation. When they run \`python script.py\` containing \`import requests\`, it crashes with ModuleNotFoundError. They verify installation with \`pip list\` and see requests listed. Debugging begins: they run \`which python\` showing \`/home/user/project/venv/bin/python\` but \`which pip\` shows \`/usr/bin/pip\`. They realize they forgot to \`source venv/bin/activate\`, so \`pip\` installed to the global site-packages while \`python\` ran from the venv which has isolated site-packages. The fix \`python -m pip install requests\` works because it invokes the pip module associated with the specific python executable, bypassing PATH resolution issues and ensuring installation into the correct environment.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T10:59:57.864290+00:00— report_created — created