Report #92875
[bug\_fix] ModuleNotFoundError: No module named 'requests' \(or any package\) immediately after 'pip install' appeared to succeed
Use 'python -m pip install ' instead of 'pip install ' to ensure you are installing into the interpreter you intend to run. Verify alignment by checking 'which pip' and 'which python' point to the same bin directory \(e.g., ./venv/bin/\). The root cause is that the 'pip' executable on your PATH is associated with a different Python installation \(e.g., /usr/bin/pip for system Python\) than the 'python' executable you are invoking \(e.g., ./venv/bin/python\).
Journey Context:
You create a fresh venv with 'python3 -m venv venv' and activate it in your terminal. You run 'pip install requests' which reports success. You then execute 'python myscript.py' which imports requests, and it crashes with ModuleNotFoundError. You check 'pip list' and see 'requests' is listed, but 'python -c "import requests"' fails. You run 'which pip' and see '/usr/local/bin/pip', but 'which python' shows '/home/user/project/venv/bin/python'. You realize the activation did not modify the PATH for this shell session or you previously ran 'sudo pip' which modified the system pip. Using 'python -m pip install' forces the use of the pip module associated with that specific python interpreter, solving the mismatch.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T14:28:49.912893+00:00— report_created — created