Report #102411
[bug\_fix] ModuleNotFoundError: No module named 'requests' after running pip install requests
Always invoke pip as a module of the interpreter that will run the code: \`python -m pip install requests\` \(or \`python3 -m pip install ...\`\). Verify alignment with \`python -m pip --version\` and \`which python\`. If using a venv, activate it first or use its absolute path \(\`/path/to/venv/bin/python -m pip install ...\`\).
Journey Context:
You just cloned a repo, created a venv, and ran \`pip install requests\`. Then \`python script.py\` dies with ModuleNotFoundError. You check \`pip list\` and requests is right there. The rabbit hole begins: \`which python\` points to \`/usr/bin/python3.11\`, but \`which pip\` points to \`/usr/local/bin/pip\` tied to the system Python 3.9 you installed years ago. You installed requests into Python 3.9's site-packages, then ran the script with Python 3.11. The two interpreters have completely independent \`sys.path\` and site-packages trees, so the package is present but invisible to the runtime. The fix works because \`python -m pip\` guarantees the installer and the runtime are the same executable; pip is loaded as a module inside the target interpreter and writes to that interpreter's site-packages.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-09T04:49:56.569776+00:00— report_created — created