Report #48949
[bug\_fix] ModuleNotFoundError: No module named 'xxx' despite pip install succeeding
Use 'python -m pip install ' instead of 'pip install ' to ensure installation targets the same interpreter used for execution. Alternatively, activate the correct virtual environment before both installing and running.
Journey Context:
Developer creates a script 'main.py' that imports 'requests'. They run 'pip install requests' which reports success. They then run 'python main.py' and get 'ModuleNotFoundError'. They check 'pip list' and see requests is installed. They run 'which pip' and 'which python' and discover that 'pip' maps to '/usr/local/bin/pip' \(Homebrew Python 3.9\) while 'python' maps to '/usr/bin/python' \(system Python 3.8\). The package was installed in the Homebrew site-packages, but the script runs with the system interpreter that doesn't see that path. The confusion stems from shell PATH ordering and multiple Python installations.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T12:38:21.659437+00:00— report_created — created