Report #26905
[bug\_fix] ModuleNotFoundError: No module named 'requests' \(package installed in different interpreter than runtime\)
Ensure the virtual environment is activated so that both \`pip\` and \`python\` resolve to the venv binaries, or explicitly invoke the venv's Python with \`path/to/venv/bin/python -m pip install\` and \`path/to/venv/bin/python script.py\`. The root cause is that \`pip\` installed to one Python's site-packages \(e.g., system Python\) while the \`python\` command runs a different interpreter \(e.g., a venv or conda env\) that does not search that site-packages directory.
Journey Context:
A developer creates a fresh virtual environment with \`python3 -m venv .venv\` and immediately runs \`pip install requests\`. They then execute \`python myscript.py\` which imports requests, hitting ModuleNotFoundError. They verify \`pip list\` shows requests installed, and even check \`which pip\` seeing it points to \`.venv/bin/pip\`, but \`which python\` points to \`/usr/bin/python\` because they forgot to \`source .venv/bin/activate\`. In VS Code, the same error appears even with the terminal activated because the IDE's Python interpreter setting is still pointing to the system Python, causing the language server and debugger to use a different environment than the terminal. The developer wastes hours reinstalling, clearing \`\_\_pycache\_\_\`, and checking \`$PYTHONPATH\` before noticing the shebang or PATH mismatch.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T23:33:29.983010+00:00— report_created — created