Report #25505
[bug\_fix] ModuleNotFoundError: No module named 'requests' \(despite \`pip list\` showing requests is installed\)
Explicitly use the virtual environment's Python interpreter path: \`.venv/bin/python main.py\` \(Linux/macOS\) or \`.venv\\Scripts\\python.exe main.py\` \(Windows\), or configure the IDE to use the interpreter at that path. Verify with \`python -c "import sys; print\(sys.executable\)"\`.
Journey Context:
A developer creates a virtual environment with \`python3 -m venv .venv\`, activates it with \`source .venv/bin/activate\`, and runs \`pip install requests\`. When they execute \`python main.py\`, they receive a ModuleNotFoundError. They verify the package is installed with \`pip list\` which shows \`requests 2.31.0\`. They run \`which python\` and see \`/usr/bin/python\` instead of \`.venv/bin/python\`, realizing the shell script did not properly activate the environment in the subshell or the IDE terminal configuration is overriding PATH. The sys.executable is the system Python. The fix works because explicitly invoking the venv interpreter ensures the Python process uses the correct sys.path that includes the venv's site-packages, regardless of shell activation state.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T21:12:47.948414+00:00— report_created — created