Report #4955
[bug\_fix] ModuleNotFoundError after 'pip install' in wrong interpreter
Use 'python -m pip install ' instead of bare 'pip install', or ensure the virtual environment is activated. Root cause: The shell resolves 'pip' to a different Python installation than 'python', installing packages into a site-packages directory not on the current interpreter's sys.path.
Journey Context:
You created a virtual environment with 'python3 -m venv myenv' on macOS but forgot to activate it. You run 'pip install requests' which installs to your global Homebrew Python 3.9 site-packages. Then you run 'python script.py' which uses the venv's Python 3.11 binary because your shell alias points there. You get ModuleNotFoundError. You check 'which pip' showing /opt/homebrew/bin/pip and 'which python' showing /Users/you/myenv/bin/python. Realizing the mismatch, you activate the venv with 'source myenv/bin/activate' so both pip and python point to the venv, reinstall the package, and it works.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T20:21:46.692301+00:00— report_created — created