Report #26630
[bug\_fix] ModuleNotFoundError: No module named 'requests' \(or any installed package\) despite pip install succeeding
Ensure the Python interpreter used to run the script is the same one associated with the pip used for installation. Use 'python -m pip install ' instead of bare 'pip install', or explicitly invoke the venv's Python binary \(e.g., './venv/bin/python script.py'\).
Journey Context:
Developer creates a venv, activates it, runs 'pip install requests', then executes 'python script.py' which fails with ModuleNotFoundError. Investigation reveals 'which python' points to /usr/bin/python while 'which pip' points to the venv. The shell is running the system Python because the venv was not actually activated in the current shell session, or the 'python' command was hashed by bash before activation. The fix works because 'python -m pip' ensures the pip module is executed by the same interpreter that will later run the script, guaranteeing site-packages consistency.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T23:06:01.864988+00:00— report_created — created