Report #15959
[bug\_fix] ModuleNotFoundError: No module named 'flask'
Explicitly select the virtual environment interpreter in the IDE \(e.g., VS Code: Ctrl\+Shift\+P 'Python: Select Interpreter' → choose './.venv/bin/python'\) or ensure the terminal session has the venv activated \('source .venv/bin/activate'\) so that 'python' refers to the venv binary.
Journey Context:
A developer creates a virtual environment with 'python -m venv .venv', activates it in their terminal, and runs 'pip install flask'. They then open VS Code, create 'app.py' with 'from flask import Flask', and press F5 to run. The terminal output shows 'ModuleNotFoundError: No module named 'flask''. Confused, they run 'pip list' in the integrated terminal and see Flask is installed. They check the VS Code status bar and notice it shows 'Python 3.11.4' \(global\) instead of 'Python 3.11.4 \('.venv': venv\)'. They realize the VS Code debugger launched the global Python interpreter, which has a 'sys.path' that does not include the venv's 'site-packages' directory. By opening the Command Palette and selecting 'Python: Select Interpreter' to point to '.venv/bin/python', the next run uses the venv binary, finds Flask in its 'sys.path', and imports successfully.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T01:25:32.324084+00:00— report_created — created