Report #4633
[bug\_fix] ModuleNotFoundError immediately after 'pip install' succeeds
Always invoke pip as a module tied to the specific Python interpreter: \`python -m pip install \` instead of the bare \`pip\` command.
Journey Context:
Developer on macOS runs \`pip install requests\` in their shell. The command succeeds and reports \`Successfully installed requests\`. They then run \`python script.py\` which contains \`import requests\`, but it crashes with \`ModuleNotFoundError: No module named 'requests'\`. They run \`pip list\` and see \`requests\` is installed. They run \`which pip\` and see \`/usr/local/bin/pip\`, but \`which python\` shows \`/usr/bin/python\`. They realize that \`pip\` is the Homebrew Python 3.11 pip, while \`python\` is the system Python 3.9. The package was installed into \`/usr/local/lib/python3.11/site-packages\`, but \`python\` looks in \`/Library/Python/3.9/site-packages\`. Using \`python -m pip\` ensures the pip module from the same prefix as the \`python\` executable is used, guaranteeing alignment between install target and runtime environment.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T19:49:39.565521+00:00— report_created — created