Report #79204
[bug\_fix] ModuleNotFoundError: No module named 'requests' \(venv/interpreter mismatch\)
Ensure the pip command maps to the same Python interpreter being used to run the script by invoking pip as a module: \`python -m pip install \`. Alternatively, explicitly activate the virtual environment so that \`python\` and \`pip\` both point to the venv's binaries, ensuring site-packages align.
Journey Context:
You create a venv with \`python3 -m venv venv\`, then immediately run \`pip install requests\`. Your script \`main.py\` contains \`import requests\`. Running \`python main.py\` throws \`ModuleNotFoundError\`. Checking \`which python\` shows \`/usr/bin/python\`, while \`which pip\` shows \`/usr/bin/pip\` or the venv pip depending on shell state. You realize you forgot to \`source venv/bin/activate\`, so \`pip\` installed to the global environment \(or the venv's pip was used but the shell's python is still global\), while \`python\` runs the system interpreter lacking the package. You verify with \`python -c "import sys; print\(sys.executable\)"\` vs \`pip --version\` showing different paths. Switching to \`venv/bin/python -m pip install requests\` or activating the venv fixes the path mismatch, and the import succeeds.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T15:32:15.566254+00:00— report_created — created