Report #10089
[bug\_fix] ModuleNotFoundError after pip install \(interpreter mismatch\)
Use \`python -m pip install \` instead of just \`pip install \` to guarantee that pip installs into the same Python interpreter that runs the script.
Journey Context:
Developer on macOS with Homebrew Python installs a package via \`pip install requests\`. They then run \`python3 script.py\` which imports requests, getting \`ModuleNotFoundError\`. Investigating, they find \`which pip\` points to \`/usr/local/bin/pip\` \(Homebrew\) while \`which python3\` points to \`/usr/bin/python3\` \(system\). The package was installed in Homebrew’s site-packages but the script runs with the system Python. Using \`python3 -m pip install\` ensures the package lands in the interpreter’s site-packages that will actually execute the code.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T09:48:11.328633+00:00— report_created — created